Message242235
| Author |
llllllllll |
| Recipients |
barry, eric.smith, eric.snow, llllllllll, rhettinger, serhiy.storchaka |
| Date |
2015年04月29日.17:18:53 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1430327934.26.0.693122555208.issue23910@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|