I would just make sure that the unpickling old matrices still works.

--Mike
--Mike


On Tue, May 21, 2013 at 2:02 PM, Jean-Pierre Flori <jpfl...@gmail.com> wrote:
>
>
> On Tuesday, May 21, 2013 2:47:07 PM UTC+2, Martin Albrecht wrote:
>>
>> Sounds like a good idea to me.
>
> Sounds good to me too.
>>
>>
>> On Tuesday 21 May 2013, Volker Braun wrote:
>> > Reposted at the top to increase visiblitiy (see
>> > https://groups.google.com/d/msg/sage-devel/5PdRIUic2Es/l0yDYLG_8qIJ)
>> >
>> > The sage matrices use unsigned long for the mod_int datatype. This does
>> > not
>> > fit into a (signed) python int, so whenever it reaches Python (assigning
>> > to
>> > a Python variable, or passing as an argument to a non-cdef function) it
>> > gets converted to a Python arbitrary-precision integer. This wastes
>> > quite a
>> > bit of time when creating it and gets worse once you start doing
>> > arithmetic:
>> >
>> > --------------------------------------
>> > ctypedef unsigned long mod_int   # this is how we define it
>> >
>> > cpdef caster_slow():
>> >     cdef int i
>> >     foo = None
>> >     for i in range(10000000):
>> >         foo = <mod_int>(1.0)
>> >
>> > cpdef caster_fast():
>> >     cdef int i
>> >     foo = None
>> >     for i in range(10000000):
>> >         foo = <int>(1.0)
>> > --------------------------------------
>> >
>> > Then we get
>> >
>> > sage: timeit('caster_slow()')
>> > 5 loops, best of 3: 137 ms per loop
>> > sage: timeit('caster_fast()')
>> > 25 loops, best of 3: 34.4 ms per loop
>> >
>> > Should we just switch to (signed) long? This wastes one bit (factor of
>> > 2)
>> > of maximum modulus length, but at least for now we define MAX_MODULUS =
>> > 2**23 so this wouldn't be an issue.
>>
>> Cheers,
>> Martin
>>
>> --
>> name: Martin Albrecht
>> _pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99
>> _otr: 47F43D1A 5D68C36F 468BAEBA 640E8856 D7951CCF
>> _www: http://martinralbrecht.wordpress.com/
>> _jab: martinr...@jabber.ccc.de
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-devel+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-devel@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-devel?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to