[Python-Dev] list.init() vs. dict.init() behaviour (original) (raw)

Stephen Thorne stephen.thorne at gmail.com
Sat Jul 15 10:44:18 CEST 2006


Hi,

When testing some 'real world' code using pypy, an inconsistancy with the way init works between lists and dicts.

The assumption was made when implementing init for pypy that list.init and dict.init would both wipe the contents of the objects, but it seems that in cpython, this isn't precisely the case.

l = [2,3] list.init(l) l []

d = {2: 3} dict.init(d) d {2: 3}

dict.init(mydict) does not wipe the keys. list.init(mylist) wipes the lists contents.

https://codespeak.net/issue/pypy-dev/issue240

Is there a good reason for this behaviour? It has broken my code (a subclass of dict that populates a key before calling the superclasses constructer, in the twisted codebase).

-- Stephen Thorne

"Give me enough bandwidth and a place to sit and I will move the world." --Jonathan Lange



More information about the Python-Dev mailing list