At 09:19 PM 4/22/04 +0200, Jiba wrote:
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
???
I believe so. However, it does occur to me it might not work for objects
that only implement the "mapping length" protocol and not the "sequence
length" protocol. So using PyObject_Length instead should work with anything.