[Python-Dev] Python 3000: Special type for object attributes & map keys

Henrik Vendelbo hvendelbo.dev at gmail.com
Wed Mar 5 22:27:32 CET 2008

It appears to me that if you can make mapping mechanisms faster in  
Python you can make significant
overall speed improvements. I also think the proposed concept could  
add flexibility to persistence formats
and RMI interfaces.

My basic idea is to have a constant string type with an interpreter  
globally unique hash. If the original constant
is created in a manner different from string constants, it can be  
tracked and handled differently by the interpreter.

Obviously most object attribute references are done with the dot  
operator, so I guess the interpreter already has
an efficient mapping mechanism. But there must be a crossover with  
__getattr__ etc, where a map of some sort is
used. I imagine that having a global namespace to translate attribute  
names into integers could be used for several
purposes by the interpreter as well as an application exchanging  
objects with other applications.

I imagine these expressions to be supported:
* attrname(string) - creates an attrname value from the string
* int(attrname) - gets the hash value
* string(attrname) - gets the string value

Hope this makes sense


P.S. I originally thought of this in a JavaScript context so forgive  
me if this would make little difference in Python.

More information about the Python-Dev mailing list