[issue23910] property_descr_get reuse argument tuple

Joe Jevnik report at bugs.python.org
Wed Apr 29 19:18:54 CEST 2015


Joe Jevnik added the comment:

I don't think that we need to worry about reusing the single argument tuple in a recursive situation because we never need the value after we start the call. We also just write our new value and then clean up with a NULL to make sure that we don't blow up when we dealloc the tuple. For example:

>>> class C(object):
...     @property
...     def f(self):
...         return D().f
... 
>>> class D(object):
...     @property
...     def f(self):
...         return 1
... 
>>> C().f
1


This works with recursive properties.
I also think that is is getting cleaned up on shutdown, if I put a pointer to garbage in the tuple, the interpreter blows up on shutdown; this makes me think that tuple_dealloc is being called somewhere. About putting the tuple on the property instance, that would nice for memory management; however, that increases the memory overhead of each property. This also means that we would only get the faster lookup after the property has been accessed once; this is fine but the current implementation makes it so that all properties are faster after any of them are looked up once. I could be wrong about the cleanup though.

I am also updating the title and headers because this issue is no longer about namedtuple.

----------
components: +Interpreter Core -Extension Modules
title: C implementation  of namedtuple (WIP) -> property_descr_get reuse argument tuple

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23910>
_______________________________________


More information about the Python-bugs-list mailing list