[capi-sig]Re: Open questions about borrowed references
On 2018-09-05 13:32, Petr Viktorin wrote:
Only the type object, <class int>, would be immortal.
This is already the case. Extension types are statically allocated, so they are effectively immortal.
On Wed, Sep 5, 2018, 13:36 Jeroen Demeyer J.Demeyer@ugent.be wrote:
On 2018-09-05 13:32, Petr Viktorin wrote:
Only the type object, <class int>, would be immortal.
This is already the case. Extension types are statically allocated, so they are effectively immortal.
I'm not at a computer right now, but AFAIK if <class int>'s refcount drops to zero, we still try to deallocate it, and that causes an assertion and terminates the interpreter. (If its death destroys the world, does it count as immortal?)
capi-sig mailing list -- capi-sig@python.org To unsubscribe send an email to capi-sig-leave@python.org
On Wed, Sep 5, 2018 at 9:36 PM Jeroen Demeyer J.Demeyer@ugent.be wrote:
On 2018-09-05 13:32, Petr Viktorin wrote:
Only the type object, <class int>, would be immortal.
This is already the case. Extension types are statically allocated, so they are effectively immortal.
Extension types don't HAVE to be statically allocated, but right now all the examples in online doco and books are. I asked about this on python-dev some months back and eventually got some hints about how C extensions might dynamically allocate types, but haven't got around to trying it yet.
It would be an improvement if only a few built in types were static and most extension types were dynamically allocated objects. As of Python 3.6 a static type cannot be a subclass of a dynamic type, it triggers an interpreter assertion, so C extensions cannot subclass anything in the standard library that isn't also static.
--
cheers,
Hugh Fisher
participants (3)
-
Hugh Fisher
-
Jeroen Demeyer
-
Petr Viktorin