thouis / numpy-trac-migration

numpy Trac to github issues migration
2 stars 3 forks source link

implement the rest of the dictionary interface for NpzFile (Trac #1125) #4928

Open numpy-gitbot opened 12 years ago

numpy-gitbot commented 12 years ago

Original ticket http://projects.scipy.org/numpy/ticket/1125 on 2009-06-03 by atmention:dwf, assigned to unknown.

The patch attached implements a more complete dictionary interface for NpzFile. That is to say, it provides (in addition to the already present getitem()):

This allows the convenient "for fname in mynpzfile" syntax, as well as letting you write code that doesn't care whether its input is an in-memory dictionary or a lazily-loaded NpzFile.

numpy-gitbot commented 12 years ago

Attachment added by atmention:dwf on 2009-06-03: io.py.diff

numpy-gitbot commented 12 years ago

atmention:dwf wrote on 2009-06-03

Oops. That should be __contains__, __iter__.

numpy-gitbot commented 12 years ago

atmention:dwf wrote on 2009-06-04

I just noticed the base classes defined in the "collections" module. I wonder if we should be inheriting from collections.Mapping, even though not all of the interface can be efficiently implemented.

numpy-gitbot commented 12 years ago

atmention:pv wrote on 2009-06-04

We can't inherit from collections.Mapping, since Python 2.4 compatibility needs to be maintained.

numpy-gitbot commented 12 years ago

atmention:dwf wrote on 2009-06-04

Good point. In that case, maybe we should inherit from [http://docs.python.org/library/userdict.html#UserDict.DictMixin UserDict.DictMixin], with a comment to the effect that this should eventually be deprecated in favour of collections.Mapping?

numpy-gitbot commented 12 years ago

Milestone changed to Unscheduled by atmention:cournape on 2009-11-27