Speed: bytecode vz C API calls

Terry Reedy tjreedy at udel.edu
Tue Dec 9 18:54:12 CET 2003


"Jacek Generowicz" <jacek.generowicz at cern.ch> wrote in message
news:tyfy8tmz7hq.fsf at pcepsft001.cern.ch...
> "Terry Reedy" <tjreedy at udel.edu> writes:
> > Can any of your callables be memoized by list rather than dict?
> > (ie, any count or restricted int args?)
>
> You've lost me there.

Lookup tables.  Dicts can memoize any function.  Lists can memoize or
partially memoize functions with one or more periodic domains.  Perhaps I am
being too obvious or simple for *you*, but I have seen people memoize fib()
or fac() with a generic dict-based wrapper, which is overkill compared to a
simple list.

In another post, you said

> If I want to compete on speed with C++, I'm
>simply going have to eliminate Python bytecode from my inner loops[*].
> [*] Unless my overall algorithm is completely wrong, of course.

For speed, you need to eliminate *executed* and *expensive* bytecodes, not
static, possibly skipped-over, bytecodes.  I'll take that as what you meant.
It is certainly what our comments are aimed at.  Hence my other suggestion
to eliminate a layer of (expensive) function calls by combining value
calculation and storage in one function (more space, less time).  More
specific suggestions will require more specific examples.

Terry J. Reedy






More information about the Python-list mailing list