logo       

Re: Quick 'len()' speedup for Pyrex: msg#00048

python.pyrex

Subject: Re: Quick 'len()' speedup for Pyrex

On Thu, 22 Apr 2004 14:05:56 -0400
"Phillip J. Eby" <pje@xxxxxxxxxxxxxxxxx> wrote:

> If your Pyrex code uses the 'len()' builtin, here's a handy quick fix
> you can pop in at the beginning of your code:
>
> cdef extern from "Python.h":
> int len "PySequence_Length" (object o) except -1

Does this work with user-defined len(), such as :

class MyClass:
def __len__(self): return 3

???

Jiba


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise