Matthew Bromberg wrote:

> I was wrong.  A buffer of the type
> cdef object[int] myhash
> can only be declared locally inside some function or method.



Ignore my last post!!!

You are confusing PEP 3118 buffers with C arrays.

You probably want this:

    DEF BUF_SIZE = 32
    cdef object myhash[BUF_SIZE]

which should work at module scope. This says "myhash is a C array of
object, of length BUF_SIZE."

Your statement

   cdef object[int] myhash

is not a Cython syntax error, but means something else:

"object is a type that exposes a PEP 3118 Py_buffer storing C integers,
and myhash is an instance of PEP 3118 Py_buffer."

A Py_buffer can only be used inside a method because of the auxillary
variables to which it unboxes for fast array lookup. Hence the error
message.

PEP 3118 syntax is mostly used with NumPy arrays for numerical programming.

Sturla Molden


_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to