Pyrex praise (repeat)

Greg Ewing see_reply_address at something.invalid
Wed Aug 7 06:18:48 CEST 2002


Terry Hancock wrote:

> it involved "fusing" a set of emotions
> (i.e. a Python list containing emotion objects, which are
> 4-vectors in the model, presumeably tuples of floats, or
> perhaps tuples of a saturating "vague number" type, like a
> fuzzy logic value).  "Fusing" is basically "summing",
> except the procedure is non-linear


Pyrex may well be able to help you here. It will
certainly be a lot easier than writing an extension
from scratch.

You might have to be careful about how you pass in
the data to the Pyrex function, though. If you just
keep it in a Python list of tuples, you may find that
the Pyrex version isn't all that much faster than
doing it in Python, because it will have to use
Python/C API calls to fetch all the values out of
the Python data structures and put the results
back in.

You should try it that way first, it might be fast
enough for you. It will be somewhat faster, just
not quite C-speed fast.

If it's not fast enough, I'd suggest using an Nx4
Numeric array to hold your list of emotion vectors,
and pass that into the Pyrex function. Since its contents
will already be in the form of C data types, Pyrex will
be able to operate on it at blazing speed.

Accessing the internals of a Numeric array from
Pyrex is fairly straightforward, although not documented
very well yet. I'll try to remedy that, but in the
meantime, let me know if you need any help with it.

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg




More information about the Python-list mailing list