On Feb 11, 7:22 pm, Basilisk96 <basilis...@gmail.com> wrote:
>...
> where "func" is a single-argument function that returns either a
> string or None, but is an expensive call.
> I am pretty sure that the sorted() construct cannot be improved much
> further, but...
> ...does anyone have ideas on improving the "rawPairs" iterator so that
> it calls "func(s)" only once per iteration?  Perhaps a lambda
> construct, but I am not sure how to go about it...?
>
> Cheers,
> Basilisk96

If func is expensive, you could try memoizing it.  Then subsequent
"calls" just do arg lookups.  Michele Simianato has posted a good
memoizing decorator on the Python wiki.

-- Paul
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to