Re: [sage-devel] Re: Significant slowdown of basic arithmetic

2019-11-24 Thread TB
On 24/11/2019 20:04, Marc Mezzarobba wrote: Marc Mezzarobba wrote: sage: def f(): : for i in [x]range(1): : 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 lon

[sage-devel] Re: Significant slowdown of basic arithmetic

2019-11-24 Thread Marc Mezzarobba
Marc Mezzarobba wrote: >> sage: def f(): >> : for i in [x]range(1): >> : 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

[sage-devel] Re: Significant slowdown of basic arithmetic

2019-11-24 Thread Marc Mezzarobba
Marc Mezzarobba wrote: > Some profiling data (via linux-perf) for > > sage: def f(): > : for i in [x]range(1): > : 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 mu

[sage-devel] Re: Significant slowdown of basic arithmetic

2019-11-23 Thread Marc Mezzarobba
Some profiling data (via linux-perf) for sage: def f(): : for i in [x]range(1): : a+a Py2: Samples: 26K of event 'cycles', Event count (approx.): 17630706503 Children Self Command Shared ObjectSymbol + 77,85%47,79% python2 libpython2.7.so.1.0

[sage-devel] Re: Significant slowdown of basic arithmetic

2019-11-23 Thread Marc Mezzarobba
Vincent Delecroix wrote: > Then I guess the reason of the slowdown comes from the change in > the integer types in Python 3 and the way we handle the conversion > from Python integers to Sage integers This may be part of it, but I don't think it explains everything: sage: a = 1 sage: %timeit a+a

Re: [sage-devel] Re: Significant slowdown of basic arithmetic

2019-11-23 Thread Vincent Delecroix
Then I guess the reason of the slowdown comes from the change in the integer types in Python 3 and the way we handle the conversion from Python integers to Sage integers. Namely we have low level mpz_set_pylong (for "long" integers) and mpz_set_si (for machine integers, which is a GMP function).

Re: [sage-devel] Re: Significant slowdown of basic arithmetic

2019-11-23 Thread John H Palmieri
On Saturday, November 23, 2019 at 12:38:35 PM UTC-8, vdelecroix wrote: > > Le 23/11/2019 à 11:34, John H Palmieri a écrit : > > By the way, Integer(1r) is also faster with Python 2 than with Python 3. > > By how much? Does it explain the 25% slowdown of the original post? > Python 2: sage: %

Re: [sage-devel] Re: Significant slowdown of basic arithmetic

2019-11-23 Thread Eric Gourgoulhon
Le samedi 23 novembre 2019 20:34:51 UTC+1, John H Palmieri a écrit : > > It's not actually Sage 8.9 vs. 9.0, it is? Rather it's Python 2 vs. Python > 3. > I confirm this: since at least Sage 8.5, Python 3 is roughly 10% slower than Python 2 in running the manifold doctests via sage -tp --long

Re: [sage-devel] Re: Significant slowdown of basic arithmetic

2019-11-23 Thread Vincent Delecroix
Le 23/11/2019 à 11:34, John H Palmieri a écrit : By the way, Integer(1r) is also faster with Python 2 than with Python 3. By how much? Does it explain the 25% slowdown of the original post? -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To uns

Re: [sage-devel] Re: Significant slowdown of basic arithmetic

2019-11-23 Thread John H Palmieri
It's not actually Sage 8.9 vs. 9.0, it is? Rather it's Python 2 vs. Python 3. On my computer, I see the same timings with Python 3 builds of 8.9 and 9.0.beta6, but things look faster with Python 2 builds of 8.9 and 9.0.beta6. By the way, Integer(1r) is also faster with Python 2 than with Python

Re: [sage-devel] Re: Significant slowdown of basic arithmetic

2019-11-23 Thread Vincent Delecroix
And could you also time compare a = Integer(1r) on both versions? Le 23/11/2019 à 11:13, Marc Mezzarobba a écrit : Vincent Delecroix wrote: @Marc: could you perform some C profiling (it might work directly inside Sage via %crun [2]). Yes, I'll try to investigate a bit more, but I first

[sage-devel] Re: Significant slowdown of basic arithmetic

2019-11-23 Thread Marc Mezzarobba
Vincent Delecroix wrote: > @Marc: could you perform some C profiling (it might work directly > inside Sage via %crun [2]). Yes, I'll try to investigate a bit more, but I first wanted to ask if it was a known issue. -- Marc -- You received this message because you are subscribed to the Google