dictionaries vs. objects

Andre Meyer meyer at acm.org
Thu Aug 24 22:06:38 EDT 2006


Hi all

I have the following question: I need a representation of a physically
inspired environment. The environment contains a large number of objects
with varying attributes. There may be classes of objects, but there is not
necessarily a strictly defined hierarchy among them. Object access should be
fast, because there a many objects that change often (e.g., moving objects).

My approach is to use a dictionary for the environment model and store each
object as a slot, which contains either a dictionary or an object. Now,
which is better? What is the performance of Python to look up attributes as
either slots of a dictionary or attributes of an object? What feels more
logical? What is more pythonic and performs better? Which is constructed and
modified easier and quicker? Are there effects that I am not yet aware of?

thanks for your thoughts
Andre
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060825/d6ddc94f/attachment.html>


More information about the Python-list mailing list