[Numpy-discussion] Scalar math module is ready for testing

Travis Oliphant oliphant.travis at ieee.org
Fri Apr 28 00:14:16 EDT 2006


The scalar math module is complete and ready to be tested.  It should 
speed up code that relies heavily on scalar arithmetic by by-passing the 
ufunc machinery.

It needs lots of testing to be sure that it is doing the "right" 
thing.   To enable scalarmath you need to

import numpy.core.scalarmath

You cannot disable it once it's enabled except by restarting Python.  If 
we need that feature we can add it. The array scalars respond to the 
error modes of ufuncs.

There is an experimental function called alter_scalars that replaces the 
Python int, float, and complex number tables with the array scalar 
equivalents.  Thus, to amaze (or seriously annoy) your Python friends 
you can do

import numpy.core.scalarmath as ncs

ncs.alter_scalars(int)

1 / 0

This will return 0 unless you change the error modes...

ncs.retore_scalars(int)

Will put things back the way Guido intended....


Please try it out and send us error reports.   Many thanks to Sasha for 
his help in getting all the code so it at least compiles and loads.  All 
bugs should be blamed on me, though...


Best,

-Travis






More information about the NumPy-Discussion mailing list