Any problems with *lots* of attributes?

Harald Massa cpl.19.ghum at spamgourmet.com
Wed Feb 4 10:58:54 EST 2004


> This is a question about the performance trade-off between two methods
> of storing data. One method is to create a separate attribute for each
> piece of data, and get/set the value according to its name. 

"Attributes of Objects" are essentially dictionaries. Access to elements of 
dictionaries is O(1), meaning: not depending on the length of the 
dictionary. (assuming there are no hash collisions)

You should try to compare performace with numeric indizes to Tuples instead 
of lists, cause tuples are invariant they may be faster.




More information about the Python-list mailing list