Speed: bytecode vz C API calls
Jacek Generowicz
jacek.generowicz at cern.ch
Tue Dec 9 04:22:38 EST 2003
Jacek Generowicz <jacek.generowicz at cern.ch> writes:
> Jacek Generowicz <jacek.generowicz at cern.ch> writes:
>
> > static int
> > memoize_init(memoizeObject* self, PyObject* args, PyObject* kwds) {
> > PyArg_ParseTuple(args, "O", &(self->fn));
>
> Obvious bug: &(self->cache) !!
>
> > Py_INCREF(self->fn);
> > self->cache = PyDict_New();
> > return 0;
Apologies, I misreported the bug. self->fn is appropriate here
... using self->fn (instread of self->cache) as the dictionary in the
other function is what was wrong, of course.
> Fixing the bug gives me a factor of 3 speedup over the class-based
> version.
This is still true.
More information about the Python-list
mailing list