You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PEP 3121, 384 refactoring applied to dbm module #59855
Robin, why do you increment refcounter for type object on every construction of dbm instance?
Also I would to see macros in uppercase if possible.
RobinSchreiber commented on Oct 7, 2012
RobinSchreibermannequin
MannequinAuthor
More actions
PEP-384 demands, among other things, that the TypeObjects themselves are transformed to Heaptypes. This means that the Typeobjects, that are created from this new stable ABI, reside within the heap and therefore have to be managed by the Python GC. This is of course done by appropriately incref- and decrefing of the specific Heaptype.
From my perspective type object is referenced by module state.
While module is present it's state hold all types exposed by module.
After module has deleted it's state has cleaned up and types has gone away — thats look good to me.
Instances of python classes (not extensions) hold ownership for it's class. I guess it done because python class can be constructed inside function and instance of this class should work after exit from that function like closure does.
In case of extension modules enough to hold type reference into module state itself.
Activity
RobinSchreiber commentedon Aug 14, 2012
Changes proposed in PEP-3121 and PEP-384 have now been applied to the dbm module!
asvetlov commentedon Oct 7, 2012
Robin, why do you increment refcounter for type object on every construction of dbm instance?
Also I would to see macros in uppercase if possible.
RobinSchreiber commentedon Oct 7, 2012
PEP-384 demands, among other things, that the TypeObjects themselves are transformed to Heaptypes. This means that the Typeobjects, that are created from this new stable ABI, reside within the heap and therefore have to be managed by the Python GC. This is of course done by appropriately incref- and decrefing of the specific Heaptype.
asvetlov commentedon Oct 7, 2012
From my perspective type object is referenced by module state.
While module is present it's state hold all types exposed by module.
After module has deleted it's state has cleaned up and types has gone away — thats look good to me.
Instances of python classes (not extensions) hold ownership for it's class. I guess it done because python class can be constructed inside function and instance of this class should work after exit from that function like closure does.
In case of extension modules enough to hold type reference into module state itself.
Thoughts?
asvetlov commentedon Oct 11, 2012
Robin, after thinking I would to agree with your decision to hold reference to type into type instance.
Please, can you describe your check like:
Why you decref only if type->tp_dealloc points to module's dealloc? What are you protected from? What other values also possible?
RobinSchreiber commentedon Nov 29, 2012
Take a look at the discussion in bpo-15653.
vstinner commentedon Dec 18, 2020
Fixed by:
commit bf69a8f
Author: Dong-hee Na <donghee.na92@gmail.com>
Date: Tue Jun 16 01:20:54 2020 +0900