2 Jan 22:02
[Cython] Array parameter...
Hi! I'm writing a method of an extension class that will take an array as an argument (or, rather, a pointer and a size, for example). Now, I don't, strictly speaking, need to access this method from Python (i.e., it can be internal to the Cython code), but I'm writing my unit tests in Python, so it'd be nice... On the other hand, I'm thinking I wouldn't want to use list or the like as the type (in a cpdef) just to accomplish this, as that would, most likely, slow things down in actual Cython-to-Cython (or C-to-C) calls. Is there a standard way of doing this sort of thing? My thinking is that I can write a simple wrapper for the Python use, which does the proper conversion, but I don't know if that's ideal... (It doesn't *have* to be an array. I just need to pass in a variable number of doubles in an efficient manner.) -- -- Magnus Lie Hetland http://hetland.org
> You could also look at using NumPy arrays with the buffer
> interface, depending on what you're doing.
Indeed. I played with that a bit; it might be the best bet, perhaps
(although sticking with only Cython has the advantage that I can ship
the generated C code, and the user needn't install anything beyond
Python).
RSS Feed