commit d00c8b214520604fb65bde426cbaf4f4b30dbba0
Author: Mateusz Paprocki <mat...@gmail.com>
Date: Tue Jun 7 01:55:11 2011 -0700
Use new parse_expr() in sympify() (#871, #976)
This makes sympify() independent of parsing tools in Python's
standard library and makes it much simpler. parse_expr() uses
modified tokenize module to split an input string into tokens,
then it applies SymPy-specific transformations, untokenizes
transformed token sequence and passes resulting string directly
to eval(). All transformations from old sympify() are supported,
but lambda -> Lambda conversion. It is possible to implement
this in the new parse_expr(), but it would make it a little more
complex, so for now I skipped it, as this kind of transformation
isn't used very often anyway (lambda tests were XFAILed).
This also fixes issue #976 and allows sympify() to handle very
large expressions, e.g.:
In [1]: e = expand((x + y + z)**50)
In [2]: s = str(e)
In [3]: %time sympify(s) == e
CPU times: user 27.13 s, sys: 0.09 s, total: 27.22 s
Wall time: 27.22 s
Out[4]: True
Previously it raised RuntimeError. Speed could be improved, by
improving tokenize module.
Old parsers (ast and ast2.4) are still available and we could
use them in future to make a more advanced version of sympify()
that doesn't care about speed and platform compatibility, but
about generality of transformations, thus we could restore
lambda support this way (e.g. sympify("...", parser="ast")).
Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To post to this group, send email to sy...@googlegroups.com.
> To unsubscribe from this group, send email to sympy+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
>
>