8.3 Speed considerations

All functions work on any Python sequence type but are optimized for use with Numerical Python (NumPy) arrays. It is strongly suggested that you install NumPy (available from http://www.numpy.org).

If you pass NumPy arrays of the correct data-type as input data to any of the functions they are passed straight to the C functions along with the stride information of the data. If you pass generic (non- NumPy) Python sequences or NumPy arrays of the wrong data-type a suntactically suitable copy of the data will be created and passed to the function. No precautions against data-losses due to downcasts are taken. Esp. when calling functions from a module of the smaller datatpes (char, uchar, short) you have to make sure all your data fits into the C representation of the respective C dataype on the machine the program is executed. 8.1

In general, when not using NumPy you should always use the default implementation pygsl.statistics or the special implementation pygsl.statistics.long in case you are sure you have only integer values. If your program needs the little speed-up that might be possible by doing the calculation on a smaller datatype you should probably not write it in plain Python anyway:)

If you have installed NumPy you can of course use arrays of all the datatypes defined by NumPy. In that case you should use the submodule that corresponds to the NumPy datatype you are using, as only that allows us to pass your NumPy array straight to the C function. See the NumPy documentation for details on the available datatypes.

See Also:

If you are still unsure whether you should use NumPy take a look at http://www.numpy.org and download your personal copy.



Footnotes

...executed. 8.1
Of course you should not pass floating point data to integer modules either.