[Numpy-discussion] Psyco MA?

Chris Barker Chris.Barker at noaa.gov
Fri Feb 7 14:41:03 EST 2003


oops, sorry about the blank message.

Paul F Dubois wrote:
> { CC to GvR just to show why I'm +1 on the if-PEP. I liked this in another

What the heck is the if-PEP ?

> Perhaps knowlegeable persons could comment on the feasibility of coding MA
> (masked arrays) in straight Python and then using Psyco on it?

Is there confusion between Psyco and Pyrex? Psyco runs regular old
Python bytecode, and individually compiles little pieces of it as needed
into machine code. AS I understand it, this should make loops where the
inner part is a pretty simple operation very fast. 

However, Psyco is pretty new, and I have no idea how robust and stable,
but certainly not cross platform. As it generates machine code, it needs
to be carefully ported to each hardware platform, and it currently only
works on x86.


Pyrex, on the other hand, is a "Python-like" language that is tranlated
into C, and then the C is compiled. It generates pretty darn platform
independent, so it should be able to be used on all platforms.


In regard to your question about MA (and any ther similar project): I
think Psyco has the potential to be the next-generation Python VM, which
will have much higher performance, and therefore greatly reduce the need
to write extensions for the sake of performance. I supsect that it could
do its best with large, multi-dimensional arrays of numbers if there is
a Python native object of such a type. Psycho, however is not ready for
general use on all platforms, so in the forseeable future, there is a
need for other ways to get decent performance. My suggestion follows:

> 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] +
> b.data[k]

This looks like it could be written in Pyrex. If Pyrex were suitably
NumArray aware, then it could work great.

What this boils down to, in both the Pyrex and Psyco options, is that
having a multi-dimensional homogenous numeric data type that is "Native"
Python is a great idea! With Pyrex and/or Psyco, Numeric3 (NumArray2 ?)
could be implimented by having only the samallest core in C, and then
rest in Python (or Pyrex)

While the Psyco option is the rosy future of Python, Pyrex is here now,
and maybe adopting it to handle NumArrays well would be easier than
re-writing a bunch of NumArray in C.

-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




More information about the NumPy-Discussion mailing list