[Cython] Storing many, many instances

Stéfan van der Walt stefan at sun.ac.za
Tue May 5 00:36:51 CEST 2009


2009/5/5 Robert Bradshaw <robertwb at math.washington.edu>:
>> Does this happen in C, or am I making Python calls along the way?
>
> You have to cimport to use C calls from another module. However, it
> will still call __init__ with Python semantics. The more arguments
> you pass (especially keyword arguments), the slower it'll get.

I feel really silly that I can't get this working, but Cython
complains that MyClass.pxd was not found, and then says:

Name 'MyClass' not declared in module 'mymodule.myclass' (but it is
defined in myclass.pxd and importable in Python as myclass.MyClass).

It doesn't look like sage.rings.Integer has a .pxd file, so I'm not
sure why mine is failing.

> You could look into PY_NEW that we use in Sage. There was a thread on
> this earlier. There is inherently overhead in using Python objects,
> but it's usually worth the convenience. Another option would be to
> write a single class that provides access to a large set your
> objects. It all depends on your use case.

Thank you, I'll have a look!

Cheers
Stéfan


More information about the Cython-dev mailing list