matching objects by a tuple field criterion

bullockbefriending bard kinch1967 at gmail.com
Sun Jun 10 13:55:38 CEST 2007


> Instead of passing a wild-card tuple like (*,*,*,4,*,*) simply pass the
> integer you want to match and the position you want to match it in.

for sure. that was more for expository purpose rather than how i was
planning to go about it.


> As a generator expression:
>
> (obj for obj in list_of_objects if obj.data[what] == where)

above or equivalent list comprehension was what i had in mind as far
as linear search goes. and scanning the list like this will most
likely be 'good enough' performance-wise. however, partly just out of
curiosity, i was wondering if there is some kind of data structure
which might let me find all the matches a bit faster.




More information about the Python-list mailing list