dicts vs classes

Simon Forman rogue_pedro at yahoo.com
Tue Jul 25 12:12:21 EDT 2006


Simon Hibbs wrote:
> I'm wondering about whether to use objects in this way or dictionaries
> for a program I'm writing at the moment. It seems to me that unless you
> need some of the functionality supplied with dictionaries (len(a),
> has_key, etc) then simple objects are a syntacticaly cleaner and more
> natural way to express yourself.
>
> Any objctions to this, or pitfalls?
>
> Simon Hibbs

I'm not sure, but I think this should be the other way round: unless
you need special behavior that dicts don't supply (methods) or you
really want/need obj.attr notation, you're better off just using dicts,
but Marco Wahl is right, if it really matters measure it.

Peace,
~Simon




More information about the Python-list mailing list