Can I do this faster?
Michael Hudson
mwh21 at cam.ac.uk
Wed Aug 9 03:20:10 EDT 2000
Horst Gassner <horst at proceryon.at> writes:
> Hello!
>
> The following code is executed very often in my program and I would be
> happy if someone could help me to speed this up.
>
> def __GetRowID (s, row):
> for key in s.__rowDict.keys():
> if s.__rowDict[key]['data'] == row:
> return key
Try this?
def __GetRowID (s, row):
return filter(lambda (k,v),r=row:v['data']==r,
s.__rowDict.items())[0][0]
It *might* be a bit faster. Not a lot, I suspect. Would you let me
know? I'm kinda curious...
HTH,
M.
--
The only problem with Microsoft is they just have no taste.
-- Steve Jobs, (From _Triumph of the Nerds_ PBS special)
and quoted by Aahz Maruch on comp.lang.python
More information about the Python-list
mailing list