[Python-3000] Adaptation [was:Re: Iterators for dict keys, values, and items == annoying :)]

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Apr 2 02:56:12 CEST 2006


Alex Martelli wrote:

> The existence of dicts is 
> a laughably feeble excuse to avoid having adaptation in Python's  
> standard library,

The point is whether it buys you anything important
over using a dict. If you use it in such a wide-open
way that it's just a mapping from anything to anything,
I don't see that it does.

Another thing that makes me way of adaptation is that
it relies on a global registry. I'm leery about global
registries in general.

One problem is that, because they're global, you only
get one of them per program. I actually think the very
existince of copy_reg is wrongheaded, because it assumes
that in any given program there will be one correct way
to copy any given type of object. On the extremely
rare occasions when I want to deep-copy something, I
have very specific ideas on how deeply I want to copy
it, and that could vary from one situation to another.
I wouldn't trust anything found in a global registry
to do the right thing.

Another problem is that, because they're global,
any part of the program can put stuff in them that
gets used by any other part, without its explicit
knowledge. This can make it hard to tell what any
given piece of code is going to do without searching
the whole program.

--
Greg


More information about the Python-3000 mailing list