Marc Mezzarobba wrote: >> sage: def f(): >> ....: for i in [x]range(100000000): >> ....: a+a > > where a = Integer(1). > > If a is made local to the function, the very expensive lookups > disappear, and we still see calls to PyLong_FromLong taking much > longer than PyInt_FromLong, as Vincent suspected.
...But these seem to come from the loop indices. And indeed: sage: def f(): ....: a = Integer(1) ....: for i in range(100000000): ....: a+a sage: %time f() # py3 CPU times: user 5.58 s, sys: 0 ns, total: 5.58 s Wall time: 5.58 s sage: import itertools sage: def f(): ....: a = Integer(1) ....: for i in itertools.repeat(1, 100000000): ....: a+a sage: %time f() # py3 CPU times: user 3.7 s, sys: 3.92 ms, total: 3.71 s Wall time: 3.71 s sage: %time f() # py2 CPU times: user 4.83 s, sys: 3.92 ms, total: 4.83 s Wall time: 4.83 s But then I don't understand why the empty loop ran faster under py3... But I also no longer manage to reproduce that observation. So maybe what one observes with that particular example is just that range() has got slower with the int/long merge? I'd be surprised, however, if this explained a 10% slowdown in so many things. -- Marc -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/qregn6%24753%241%40blaine.gmane.org.