On Dec 1, 2009, at 10:02 AM, Martin Albrecht wrote:

> Hi there,
>
> the following code is really, really really (REALLY!) slow:
>
> sage: IP = InfinitePolynomialRing(QQ)
> sage: x = IP.gen()
> sage: x10000 = x[10000]
> sage: %time 1/2*x10000
> CPU times: user 0.86 s, sys: 0.00 s, total: 0.86 s
> Wall time: 0.87 s
> 1/2*x10000

Ouch, that is pretty bad. Looks like something changed in 4.2, it's  
doing a huge amount of regular expressions stuff...

sage: %prun 1/2*x10000
          160277 function calls in 1.002 CPU seconds
    Ordered by: internal time

    ncalls  tottime  percall  cumtime  percall filename:lineno(function)
         2    0.719    0.359    1.000    0.500  
infinite_polynomial_ring.py:595(__getitem__)
     20002    0.133    0.000    0.189    0.000 {built-in method sub}
     20002    0.047    0.000    0.059    0.000 re.py:229(_compile)
     20002    0.033    0.000    0.281    0.000 re.py:144(sub)
     20002    0.028    0.000    0.056    0.000 re.py:271(_subx)
     20002    0.019    0.000    0.028    0.000 re.py:251(_compile_repl)
     40004    0.016    0.000    0.016    0.000 {method 'get' of 'dict'  
objects}
     20018    0.006    0.000    0.006    0.000 {isinstance}
         1    0.001    0.001    1.002    1.002 <string>:1(<module>)
         5    0.000    0.000    0.000    0.000  
infinite_polynomial_element.py:1053(__init__)
         1    0.000    0.000    0.000    0.000  
infinite_polynomial_element.py:1151(_add_)

- Robert

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to