[Python-Dev] Re: my plans for subinterpreters (and a per-interpreter GIL)

2021年12月15日 16:46:02 -0800

>> It does seem a bit silly to actually be tracking that refcount :-)
Not that silly. It can easily help in C extensions to detect wrong DECREF
calls:
>> import ctypes
>> non = ctypes.c_long.from_address(id(None))
>> non.value = 10
>>
Fatal Python error: none_dealloc: deallocating None
Python runtime state: finalizing (tstate=0x000055c66cf263f0)
Current thread 0x00007f4afa383740 (most recent call first):
 <no Python frame>
[1] 635685 abort (core dumped) python
On 2021年12月16日 at 00:31, Christopher Barker <[email protected]>
wrote:
> On Wed, Dec 15, 2021 at 3:00 PM Guido van Rossum <[email protected]> wrote:
>
>
>> who cares if the refcount for None is 5000 or 1610612736? As long as the
>> refcount of *mortal* objects is the same as it was before, this shouldn't
>> be a problem.
>>
>
> indeed:
>
> $ python -c "import sys; print(sys.getrefcount(None))"
> 4110
>
> and a newly started iPython session:
>
> In [2]: sys.getrefcount(None)
> Out[2]: 28491
>
> It does seem a bit silly to actually be tracking that refcount :-)
>
> -CHB
>
> --
> Christopher Barker, PhD (Chris)
>
> Python Language Consulting
> - Teaching
> - Scientific Software Development
> - Desktop GUI and Web Development
> - wxPython, numpy, scipy, Cython
> _______________________________________________
> Python-Dev mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at
> https://mail.python.org/archives/list/[email protected]/message/36N4I4CJ53OR3CLDJSJUIXEAS3NIFURP/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/QNFHXI2IQYU7RDTUPMRITEPKNEXACQWK/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to