Retrieving a specific object from a list?

andrew cooke andrew at acooke.org
Thu Apr 9 07:53:46 EDT 2009


andrew cooke wrote:
[...]
> but when you need to access instances by more than one value (.bar and
> .baz) then typically that's a hard problem, and there's a trade-off
> somewhere.  you might find writing a special container that contains two
> dicts is useful.  if so, you might want to use weak references - see
> weakref module).

thinking a bit more about when this has occurred in my own programs, and
it tends to be when i've ended up with a monster object/collection that is
trying to do too many different things (typically because i am worrying
about performance when i shouldn't be).  in that case the fix has been to
break things up and use simpler collections for each step, converting as
necessary between steps.

andrew




More information about the Python-list mailing list