Speed: bytecode vz C API calls
Jacek Generowicz
jacek.generowicz at cern.ch
Tue Dec 9 04:05:21 EST 2003
"Terry Reedy" <tjreedy at udel.edu> writes:
> "Jacek Generowicz" <jacek.generowicz at cern.ch> wrote in message
> news:tyf7k171jbq.fsf at pcepsft001.cern.ch...
> > I have a program in which I make very good use of a memoizer:
> >
> > def memoize(callable):
> > cache = {}
> > def proxy(*args):
> > try: return cache[args]
> > except KeyError: return cache.setdefault(args, callable(*args))
> > return proxy
> ...
> > I've got to the stage where my program is still not fast enough, and
> > calls to the memoizer proxy are topping profiler output table. So I
> > thought I'd try to see whether I can speed it up by recoding it in C.
>
> Have you tried psyco on above?
Nope, but psyco would be politically unacceptable for my users, in
this case. OTOH, I've been wanting to play with psyco for ages ...
> Can any of your callables be memoized by list rather than dict?
> (ie, any count or restricted int args?)
You've lost me there.
More information about the Python-list
mailing list