[Numpy-discussion] Psyco MA?

Paul F Dubois paul at pfdubois.com
Fri Feb 7 13:48:04 CST 2003

{ CC to GvR just to show why I'm +1 on the if-PEP. I liked this in another
language I used to use; Perl ? }

Perhaps knowlegeable persons could comment on the feasibility of coding MA
(masked arrays) in straight Python and then using Psyco on it? The existing
implementation is in pure python and uses Numeric to represent the two
arrays it holds (the data and sometimes a mask) in each object. A great deal
of wasted motion is devoted to preparing Numeric arrays so as to avoid
operations on masked elements. 

It could have been written a lot simpler if performance didn't dictate
trying to leverage off Numeric. In straight Python one can imagine an add,
for example, that was roughly:
    for k in 0<= k < len(a.data):
       result.mask[k] = a.mask[k] or b.mask[k]
       result.data[k] = a.data[k] if result.mask[k] else a.data[k] +

(using the new if expression PEP just to confuse the populace)

It seems to me that this might be competitive given the numbers someone
posted before. Alas, I can't remember who was the original poster, but I'd
guess they might have a good guess.

> -----Original Message-----
> From: numpy-discussion-admin at lists.sourceforge.net 
> [mailto:numpy-discussion-admin at lists.sourceforge.net] On 
> Behalf Of Chris Barker
> Sent: Friday, February 07, 2003 10:34 AM
> To: falted at openlc.org; numpy-discussion at lists.sourceforge.net
> Subject: Re: [Psyco-devel] RE: [Numpy-discussion] Interesting 
> Psyco/Numeric/Numarray comparison
> Francesc Alted wrote:
> > For this task may be is worth to consider using Pyrex
> > (http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/) for 
> that. From 
> > the
> > website:
> > 
> > """Pyrex lets you write code that mixes Python and C data types any 
> > way you want, and compiles it into a C extension for Python."""
> I've been keeping my eye on Pyrex for a while now, but have 
> not yet had enough of a use for it to justify tryin git out. 
> I do ahve a question that I ahve not foudn the answer to on 
> the web, which could make a big difference to how useful it is to me:
> Is Pyrex aware of Numeric Arrays?
> I imagine it could use them just fine, using the generic 
> Python sequence get item stuff, but that would be a whole lot 
> lower performance than if it understood the Numeric API and 
> could access the data array directly. Also, how does it deal 
> with multiple dimension indexing ( array[3,6,2] ) which the 
> standard python sequence types do not support?
> As I think about this, I think your suggestion is fabulous. 
> Pyrex (or a
> Pyrex-like) language would be a fabulous way to write code 
> for NumArray, if it really made use of the NumArray API.
> Thanks for your input,
> -Chris
> -- 
> Christopher Barker, Ph.D.
> Oceanographer
> NOAA/OR&R/HAZMAT         (206) 526-6959   voice
> 7600 Sand Point Way NE   (206) 526-6329   fax
> Seattle, WA  98115       (206) 526-6317   main reception
> Chris.Barker at noaa.gov
> -------------------------------------------------------
> This SF.NET email is sponsored by:
> SourceForge Enterprise Edition + IBM + LinuxWorld = Something 
> 2 See! http://www.vasoftware.com 
> _______________________________________________
> Numpy-discussion mailing list Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion

More information about the Numpy-discussion mailing list