Hi Florent,

On 22 Mai, 10:37, Florent Hivert <florent.hiv...@univ-rouen.fr> wrote:
> I had a very similar problem with the test suite error messages which sometimg
> slowed sown the suite but several order of magnitude. I solved this issue in
> #8742 by creating a class for lazy format string. I'm not sure this will solve
> your problem but if it does, maybe it is not a good idea to duplicate a
> feature.
>
>...
>
> In my usecases, I had some error message containing some " %s "%(bla) where
> the conversion from bla to its string representation take some time. So my
> idea was to create a class LazyFormat inheriting from str to create an object
> sur that the % operator is only evaluated when __repr__ is called. I still
> create the instance of LazyFormat which take a little time. I'm not sure how
> this fits your usecase.

It certainly sounds interesting!

However, there are two problems: The error message is slightly
different for extension classes and other classes.
raise_attribute_error and AttributeErrorMessage do a case distinction
that seems difficult to mimmick with lazy format strings.

Moreover, according to some tests that I just posted on the ticket,
they are simply too slow.

I wrote a Cython function that repeated raising and catching an
attribute error n times.
- raise_attribute_error in unpatched sage needs about 20 seconds for
n=10^7 iterations.
- raising an error with an AttributeErrorMessage as argument needs
about 3 seconds for n=10^7 iterations.
- raising an error with a lazy format string as argument needs about
16 seconds for only n=10^6 iterations.

Cheers,
Simon

-- 
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