Lazy-evaluation lists/dictionaries

Jon Ribbens jon+usenet at unequivocal.co.uk
Mon Oct 27 16:03:49 CET 2014


On 2014-10-26, Terry Reedy <tjreedy at udel.edu> wrote:
> On 10/26/2014 10:14 AM, Jon Ribbens wrote:
>> Is there any better way to do this other than simply re-implementing
>> these types from scratch, emulating all their methods and operations?
>> (i.e. using UserList/UserDict). I was under the impression that that
>> sort of thing was supposed to have gone since Python 2.2 or so.
>
> We considered dropping UserDict and UserList for 3.0 but kept them in 
> collections for cases in which subclassing does not work.

It seems on further investigation to be hard/impossible to subclass
Python classes from C extensions. I've gone with subclassing dict,
and reimplementing most of its methods. It helps that I only need it
to be read-only. It's a pity there's no protocol for 'dynamic'
lists/dicts though.



More information about the Python-list mailing list