Re: [sage-support] Re: efficient way to convert str to rational

2011-05-10 Thread Robert Bradshaw
On Tue, May 10, 2011 at 12:53 PM, tvn wrote: > sorry my question wasn't so clear --  but yes the main bottleneck is > applying the conversion function from string to rational .   Thanks for the > sage_eval function If the sage_eval function is faster, then string -> Rational needs to be fixed. s

[sage-support] Re: efficient way to convert str to rational

2011-05-10 Thread tvn
sorry my question wasn't so clear -- but yes the main bottleneck is applying the conversion function from string to rational . Thanks for the sage_eval function -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support

[sage-support] Re: efficient way to convert str to rational

2011-05-10 Thread Simon King
PS On 10 Mai, 20:06, Simon King wrote: >   sage: [QQ(sage_eval(s)) for s in list(R)[0]] That would also work on other number representations, such as 1.3E2: sage: QQ(sage_eval('1.3E2')) 130 Best regards, Simon -- To post to this group, send email to sage-support@googlegroups.com To unsubs

[sage-support] Re: efficient way to convert str to rational

2011-05-10 Thread Simon King
On 10 Mai, 19:23, tvn wrote: > > I suggest to use the csv module of Python. > > but bottleneck is not reading the data file but rater applying  the > conversion from s -> rat  .    Also I can't just use QQ(s)  ,  because s can > be something like '1.2'   OK. First, I undeerstood that your questio

[sage-support] Re: efficient way to convert str to rational

2011-05-10 Thread tvn
> > > > I suggest to use the csv module of Python. > > but bottleneck is not reading the data file but rater applying the conversion from s -> rat .Also I can't just use QQ(s) , because s can be something like '1.2' -- To post to this group, send email to sage-support@googlegro

[sage-support] Re: efficient way to convert str to rational

2011-05-10 Thread Simon King
Hi all! On 10 Mai, 16:33, ObsessiveMathsFreak wrote: > I think you should definitely get rid of the try/except statements. Is that really the case? Using try/except is a very common tool in Python. > The conversion is either going to work, or it is not, so you really > don't need them and they'

[sage-support] Re: efficient way to convert str to rational

2011-05-10 Thread ObsessiveMathsFreak
I think you should definitely get rid of the try/except statements. The conversion is either going to work, or it is not, so you really don't need them and they're probably slowing everything down a LOT. If the database is very large, you might want to consider converting outside of sage, with a c