On Wed, 15 Nov 2006 14:00:11 -0800, Martin Albrecht <[EMAIL PROTECTED]> wrote:\ > I've implemented a very naive cache for finite extension field elements > in the > Givaro wrapper. Basically, all elements are created when the field is > created > and references are returned by the arithmetic methods: Thus, no objects > are > created, no malloc, nothing. The speed-up is noticeable:
I think this is great for certain things. Thanks! > Drawbacks: > * creation of finite extension fields takes 0.3s instead of 0.14s > (without) Not bad. > * up to 2^16 * (5 * sizeof(int)) bytes are required for the storage > ( ~ 1.25 MB) depending on the size of the field That's not too bad... > * Speed-up would not be as dramatic as seen here if all the little > tricks for > object creation would have been used in the Givaro wrapper. Those tricks are also very impressive. > * Python loops slow us down significantly. How so? I.e., is that because of your new caching? Or is that just a general remark. This is another motivation to work hard to make Pyrex easier and easier to use. > Possible Improvements: > * use a C array instead of a tuple (bit smaller & faster) Makes sense. Note that you can use PySequence_Fast_ITEMS and PySequence_Fast to get direct access to the underlying C array of objects in a tuple. > My question: Are we willing to spent 1.25 MB of RAM per finite > (extension) > field for a < 3x speed-gain? Could it be optional, or is it too difficult to make both options available? How much memory does a Givaro Python class take? Robert Bradshaw and I just did an analysis of the memory used for an element of Z/nZ (for n small), and a single element takes 24 bytes in SAGE now: 4 an int (the underlying value) 4 pointer to the parent 4 pointer to the modulus 4 pointer to the function call table 8 PyObject_HEAD (pointer to type object and reference count) With your cache of the full finite field, it takes only 4 bytes (on a 64-bit machine) to store any element. This could be very useful in some applications. -- William --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---