> Say for example if I tried:
>
> cdef list quatList
> cdef Quaternion q
> for q in quatList: q.expensiveOperation()
>
> You're saying there will be expensive or sub-optimal things happening behind
> the scenes?
sub-optimal, sort of -- you'll get a pyhon list of python objects,
which is a re-sizable array of pointers to python objects, so a bit of
extra memory overhead, but if a Quaternion object is more than a
handful of bytes, not much.
then when you loop through the list, you'll be getting python objects,
and the method is called on them -- a bit of extra overhead.
but if expensiveOperation() lives up to its name, then all that will
get lost in the wash anyway.
Where you'd want to do something different is if you had a
not-very-expensive operation, that you needed to do a lot on a lot of
objects. In which case, I think Robert was suggesting that rather than
have a python object (even a cdef class) for your core object, you
structure your code around arrays of primative objects -- so have an
_array_of_quaterenions as a first class object. In that case, each one
would be 16? floating point numbers, and could all be packed together
in an array. Your some_operation() method would then do the loop
through the _array_of_quaterenions, and this could easily be
cythonized to be raw-C speed, with memory localized at all that.
By the way, I have a vague memory that someone had written a
quaternion numpy dtype a couple years ago -- maybe you could use that?
-Chris
Or this simply won't work without casting? Generally how would
> you advise approaching this in a high performance fashion within Cython ?
>
>
> Thanks again for your help.
>
>
>
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "cython-users" group.
> To unsubscribe from this group, send email to
>
cython-users...@googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R
(206) 526-6959 voice
7600 Sand Point Way NE
(206) 526-6329 fax
Seattle, WA 98115
(206) 526-6317 main reception
Chris....@noaa.gov