[sage-devel] Re: coercion, categories, and slow code

2009-12-02 Thread YannLC
first, you might be interested by this: L = zip(Vars,p.lm().exponents()[0].sparse_iter()) its faster but still not enough... then you might look at http://trac.sagemath.org/sage_trac/ticket/7587, apply it ( review it ;) ) and do L = [(Vars[i],e) for i,e in enumerate(p.lm().exponents (as_ETuples=

[sage-devel] Re: coercion, categories, and slow code

2009-12-02 Thread Simon King
Hi! On 2 Dez., 17:47, Simon King wrote: [...] > IIRC, I tried various other methods (without strings), but they were > all slower. However, I don't remember any concrete examples. > So, it would help me if you commented > onhttp://trac.sagemath.org/sage_trac/ticket/7580 > what I should try inste

[sage-devel] Re: coercion, categories, and slow code

2009-12-02 Thread Simon King
Hi William! On 2 Dez., 17:26, William Stein wrote: ... > I'm not surprised.  Looking through the code, its use of strings and > regular expressions is fairly delicate -- I wouldn't use regular > expressions at all to implement the same functionality (and more). But > I'm not rewriting anything (t

Re: [sage-devel] Re: coercion, categories, and slow code

2009-12-02 Thread William Stein
On Wed, Dec 2, 2009 at 4:36 AM, Nathann Cohen wrote: > Hello everybody > > Concerning the use of InfinitePolynomialRing in Sage, it was discussed > in another thread and I since wrote a patch (#7561)  to change it. As > mentionned, I need nothing of what this class has been built for, and > n

[sage-devel] Re: coercion, categories, and slow code

2009-12-02 Thread Nathann Cohen
Hello everybody Concerning the use of InfinitePolynomialRing in Sage, it was discussed in another thread and I since wrote a patch (#7561) to change it. As mentionned, I need nothing of what this class has been built for, and now that it is replaced with plain "var", it is a thousand times f

[sage-devel] Re: coercion, categories, and slow code

2009-12-02 Thread Simon King
Hi! On Dec 2, 6:40 am, William Stein wrote: > On Wed, Dec 2, 2009 at 1:01 AM, Mike Hansen wrote: > > On Wed, Dec 2, 2009 at 12:57 PM, William Stein wrote: > >> WTF?  Regular expressions?!?! There are regular expressions in InfinitePolynomialRing, but (at least after applying my patch) I don't

Re: [sage-devel] Re: coercion, categories, and slow code

2009-12-01 Thread William Stein
On Wed, Dec 2, 2009 at 1:01 AM, Mike Hansen wrote: > On Wed, Dec 2, 2009 at 12:57 PM, William Stein wrote: >> WTF?  Regular expressions?!?! > > The following messages are probably relevant for the fast conversion > between singular polynomial rings: Thanks. There's also regular expression stuf

Re: [sage-devel] Re: coercion, categories, and slow code

2009-12-01 Thread Mike Hansen
On Wed, Dec 2, 2009 at 12:57 PM, William Stein wrote: > WTF?  Regular expressions?!?! The following messages are probably relevant for the fast conversion between singular polynomial rings: On Sat, Oct 18, 2008 at 2:55 AM, Michael Brickenstein wrote: > In Singular the same thing is essentially

Re: [sage-devel] Re: coercion, categories, and slow code

2009-12-01 Thread William Stein
WTF? Regular expressions?!?! On Tue, Dec 1, 2009 at 6:57 PM, Simon King wrote: > Hi! > > Here is a first ticket, with patch: > http://trac.sagemath.org/sage_trac/ticket/7578 > > It reduces the computation time of the original example of this thread > to the time that is needed to convert the un

[sage-devel] Re: coercion, categories, and slow code

2009-12-01 Thread Simon King
Hi! Here is a first ticket, with patch: http://trac.sagemath.org/sage_trac/ticket/7578 It reduces the computation time of the original example of this thread to the time that is needed to convert the underlying finite polynomials. Hence, as long as the conversion does not improve, it seems to m

[sage-devel] Re: coercion, categories, and slow code

2009-12-01 Thread Simon King
On 1 Dez., 21:57, Nick Alexander wrote: [...] > I'm certain you are aware, but there is an art to optimizing regular   > expressions.  It might be that a tuned regex is necessary, rather than   > avoiding a regex altogether. Can you suggest some manual that can teach me about optimizing regular e

[sage-devel] Re: coercion, categories, and slow code

2009-12-01 Thread Simon King
Hi! I just found that part of the problem is coercion -- or actually conversion -- for classical polynomial rings: sage: R1 = PolynomialRing(QQ,'x',10001) sage: R2 = PolynomialRing(QQ,'x',10002) sage: x1 = R1('x1') sage: %prun a = R2(x1) 160026 function calls in 5.073 CPU sec

Re: [sage-devel] Re: coercion, categories, and slow code

2009-12-01 Thread Nick Alexander
> Nevertheless, the regular expression business isn't good either. I'll > see what I can do -- recent sage-devel/sage-support threads indicated > some improvements. I'm certain you are aware, but there is an art to optimizing regular expressions. It might be that a tuned regex is necessary, rat

[sage-devel] Re: coercion, categories, and slow code

2009-12-01 Thread Simon King
Hi Martin! On 1 Dez., 20:30, Martin Albrecht wrote: [...] > Sure, but up to 50 seconds for a simple coercion seems way way too much even > in that case. Agreed. Let's try to find out what happens here. My first thought was that it is due to the huge polynomial rings. But the following seems to

Re: [sage-devel] Re: coercion, categories, and slow code

2009-12-01 Thread Martin Albrecht
On Tuesday 01 December 2009, Simon King wrote: > Hi Martin! > > On 1 Dez., 19:02, Martin Albrecht > > wrote: > > Hi there, > > > > the following code is really, really really (REALLY!) slow: > > Well, the default implementation creates a polynomial ring with 1 > variables in the background

[sage-devel] Re: coercion, categories, and slow code

2009-12-01 Thread Simon King
Hi Robert! On 1 Dez., 19:18, Robert Bradshaw wrote: [...] > Ouch, that is pretty bad. Looks like something changed in 4.2, it's   > doing a huge amount of regular expressions stuff... It does a lot of regular expressions in the background. I did not see a way to do it better. However, the code d

[sage-devel] Re: coercion, categories, and slow code

2009-12-01 Thread Simon King
Hi Martin! On 1 Dez., 19:02, Martin Albrecht wrote: > Hi there, > > the following code is really, really really (REALLY!) slow: Well, the default implementation creates a polynomial ring with 1 variables in the background when you say x[1], and another ring with 10001 variables if you th