On Thu, 12 Mar 2020 at 19:05, Chris Angelico <ros...@gmail.com> wrote:
> The action of deleting a *name* is not the same as disposing of an
> *object*. You can consider "del x" to be very similar to "x = None",
> except that instead of rebinding to some other object, it unbinds x
> altogether.

Exactly. But if `x = None` will return the previous value of x, the
refcount of the object will be not decreased, and Python does not free
the object memory.
An example:

(venv) marco@buzz:~/sources$ python
Python 3.8.2 (tags/v3.8.2-dirty:7b3ab5921f, Mar  1 2020, 16:16:55)
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from sys import getrefcount
>>> a = "nfnjgjsbsjbjbsjlbslj"
>>> getrefcount(a)
2
>>> a
'nfnjgjsbsjbjbsjlbslj'
>>> getrefcount(a)
3
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/3GI25DLEUA2LRLXFH5BJ5UGDWVEBMXSA/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to