Guido van Rossum wrote: >>Same here. I would not vote to make strings or tuples or any other >>tiny type weak-reffed in the first place. >>Instead I would add the possible support to derived types, via >>the __slot__ mechanism for instance. >>There is a little coding necessary to make the generic code >>handle the case of var-sized objects, but this is doable >>and not very complicated. >> >>This may be really needed or not. if we can create the rule >>"every derived type *can* have weak-refs", this is simpler >>to memorize than "well, most can, some cannot". > > > With some (considerable?) effort, slots on var-sized objects can > certainly be supported -- the same approach as used for __dict__ > should work. I expect it might slow down the normal case a bit, > unless you define a new descriptor type just for this. Yes, I didn't recognize the tricky implementation until you said this. _PyObject_GetDictPtr looks at the end of the object if type->tp_dictoffset is < 0. This would become more complicated in the presence of weakref and other slots. Well, fairly, they would simply all store their offset from the end of the object. A not so costly approach could be to change slots a little: The slot offset is now computed on the beginning of the object's structure. There could be either a type flag that says "you must add an offset", or a new type slot which is either a function that computes and additional offset, or NULL. It would probably even suffice to check if varsize is nonzero and then do a little computation to bump the offset. cheers - chris -- Christian Tismer :^) <mailto:tismer at stackless.com> Mission Impossible 5oftware : Have a break! Take a ride on Python's Johannes-Niemeyer-Weg 9a : *Starship* http://starship.python.net/ 14109 Berlin : PGP key -> http://wwwkeys.pgp.net/ work +49 30 89 09 53 34 home +49 30 802 86 56 mobile +49 173 24 18 776 PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04 whom do you want to sponsor today? http://www.stackless.com/
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4