Speed: bytecode vz C API calls

Michael Hudson mwh at python.net
Tue Dec 9 09:30:25 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?  Or rather, on the proxies?

I doubt that would help -- the largest overhead is likely the function
call, and I think calling across the pysco/python boundary is
expensive.

Cheers,
mwh

-- 
  Screaming 14-year-old boys attempting to prove to each other that
  they are more 3133t than j00.
         -- Reason #8 for quitting slashdot today, from
            http://www.cs.washington.edu/homes/klee/misc/slashdot.html




More information about the Python-list mailing list