The future of Python immutability

sturlamolden sturlamolden at yahoo.no
Fri Sep 4 22:23:06 EDT 2009


On 3 Sep, 20:03, John Nagle <na... at animats.com> wrote:

>      Python doesn't have immutable objects as a general concept, but
> it may be headed in that direction.  There was some fooling around
> with an "immmutability API" associated with NumPy back in 2007, but
> that was removed.  As more immutable types are added, a more general
> approach may be useful.

I one did a test of NumPy's mutable arrays against Matlab's immutable
arrays on D4 wavelet transforms. On an array of 64 MB of double
precision floats, the Python/NumPy version was faster by an order of
magnitude. On the other hand, immutable arrays does make
multithreading easier. They are particularly interesting for GPGPUs
(OpenCL/CUDA) where multithreading is pervasive. Also they allow
removal of temporary arrays, which are created by NumPy's binary
operators.













More information about the Python-list mailing list