"Martin v. Löwis" wrote: > Raymond Hettinger wrote: > > Instances of classes inheriting from str, tuple, etc cannot > be weakly > > referenced. Does anyone know the reason for this? > > In addition to the reason Christian gave, one (conceptually more > important) reason is that strings can't participate in cycles. Weak > references were introduced as a mechanism to avoid creating cyclic > structures, so that "backward" links could be made weak references. > > It appears that people have then been eager to add weakref support > to other datatypes. IMO, they have been too eager. For example, I > can't see a reason why Unicode objects should be weakly referencable > (just as I can't see a reason for plain strings). Never rule out "foolish" consistencies. I can imagine a system where multiple, heterogeneous values all get run through a weakref processor; to have string objects pass through without Yet Another try/except would be a design and maintenance boon. Quite similar to my current "pet peeve": >>> None > 3 False >>> None > 'hoopy' False >>> None > True False >>> None > datetime.date(2004, 5, 31) Traceback (most recent call last): File "<interactive input>", line 1, in ? TypeError: can't compare datetime.date to NoneType ...writing an O-R mapper, this particular hobgoblin bites me rather often ;) Robert Brewer MIS Amor Ministries fumanchu at amor.org
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