dicts + amb

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Wed Oct 11 17:10:17 EDT 2006


I have implemented yet another Odict class:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/498195
It's very slow, but it is O(1) for get, set and del too.

I have added ritervalues(), rkeys(), etc methods because I presume I
can't use the reversed(). So can an __riter__ hook be generally useful?
(I have seen few comments about it in the discussion regarding PEP
322).

What's the meaning of .updated() called without arguments? Can it
become an error in Python 3.0?

In practice I don't have problems using dict get() and pop() methods,
but their calling behaviour seem a bit incoherent. Both accept a second
value, that can be None too, that they return if the key is absent, but
the get() returns the None even if you don't specify it, while pop()
return a TypeError if you don't give explicitely something (like None)
as second argument. (Maybe in practice they are more useful if kept
with such different calling behaviour.)

------------

Something unrelated that I don't know where to put.
Recently I have seen the amb operator, it's not a simple operator. I
have seen a (very simple) Ruby implementation:
http://www.randomhacks.net/articles/2005/10/11/amb-operator
I think a good amb implementation is a very complex thing. Can such
operator be useful for Python too?

Bye,
bearophile




More information about the Python-list mailing list