upiterbarg / mpmath

Automatically exported from code.google.com/p/mpmath
Other
0 stars 0 forks source link

Matrix item access #145

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
A simple speedup was implemented in r910.

One could go further by doing something like this:

    def __getitem__(self, key):
        try:
            return self.__data[key]
        except KeyError:
            ...

However, this could lead to slowdown in some situations and so needs
benchmarking.

Original issue reported on code.google.com by fredrik....@gmail.com on 4 May 2009 at 8:26

GoogleCodeExporter commented 9 years ago
Thank you for the speedup!

I think I tried this variant and it was horribly slow, but this should be 
verified.
Please note that an KeyError is a common case, because zeros are not stored.

Please note that __getitem__/__setitem__ was optimized in no way, so there 
should be
plenty room for improvement. :)
For instance I did not test whether mpmathify(mpf) could be made faster 
(because it's
called called each time in __setitem__). It could use the same trick you 
implemented
in r910.

Original comment by Vinzent.Steinberg@gmail.com on 5 May 2009 at 1:50