Just a couple of modest suggestions for new features. Nothing earth-shattering here but I think these would give a lot of bang for the buck. 1. sscanf functionality: I know this has been discussed for years, but it's time to bite the bullet and do it. 2. Sets are a useful addition to the language, but sorted sets (and dictionaries) would be more useful. C++/Java/C# all provide these types. In particular I'd like to see: A. Dictionaries support union, intersection, and symmetric difference operations as sets do. B. (Sorted) Dictionaries and sets support slicing operations: E.g. dict['a':'z'] should return a sub-dictionary with all the keys between 'a' and 'z'. C. Binary searching for items in sorted sequence and mapping types. D. Ability to handle multiple getitems at once in sequence and mapping types (Akin to what can be done in numarray). Certainly there is no good reason why lists/tuples shouldn't support list[iterable] (not to be confused with list(iterable)) which returns or dictionaries support something like dict.getm(iterable). Mark Lake
On Thu, May 20, 2004 at 01:31:09PM -0400, Mark.Lake@aigfpc.com wrote: [...]
2. Sets are a useful addition to the language, but sorted sets (and dictionaries) would be more useful. C++/Java/C# all provide these types. In particular I'd like to see:
A. Dictionaries support union, intersection, and symmetric difference operations as sets do.
What's the intersection of {'a': 1} and {'a': 2}? {'a': (1, 2)}? What about of {1.0: 'one point oh'} and {1: 'one'}? Also, this would place a significant burden on people trying to implement their own classes that present a dictionary-like interface, although perhaps UserDict.DictMixin could help there... A PEP for this that's more than a sentence long would probably be a good idea :) [...]
C. Binary searching for items in sorted sequence and mapping types.
See the bisect module. I'm not sure what binary searching of a mapping type would mean, though (I guess you mean for your proposed sorted dictionary type?).
D. Ability to handle multiple getitems at once in sequence and mapping types (Akin to what can be done in numarray). Certainly there is no good reason why lists/tuples shouldn't support list[iterable] (not to be confused with list(iterable)) which returns or dictionaries support something like dict.getm(iterable).
Well, one reason is that it places a greater burden on people implementing __getitem__, and it doesn't really offer much improvement over: [l[x] for x in iterable] Or for dictionaries: dict(d[x] for x in iterable) # Assuming 2.4's generator expressions. -Andrew.
participants (2)
-
Andrew Bennetts
-
Mark.Lake@aigfpc.com