I used "git grep 'exec '" on the repo to find all the statements. It
looks like your main problems are lines like
exec "from sympy import *" in global_dict
You may want to just skip some files, such as the test runner (and all
the tests, for that matter), and lambdify.py (which probably won't be
useful to you).
This mainly leaves the parser, which you'll probably want. I think you
could replicate the above code using __import__ (I'm not sure what the
exact code would look like at the moment).
Also, is eval() supported? I'm assuming not, since it's basically the
same as exec. This is a little harder to find by grepping, since we
have a lot of methods called eval, but I think there aren't really any
important ones (i.e., ones that you can't just remove file for).
By the way, could you perhaps push your refactoring up to a branch at
GitHub? It likely won't be merged (unless there are no side effects
from it), but I think it would still be interesting for people to see
what you needed to do, and perhaps it would help others who may want
to get it to run in pyjamas.
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.
>
>
You will actually find that the modules are more interlinked than you
might expect. For example, the functions module relies on the ntheory
module to evaluate some functions at numeric arguments (e.g.,
perfect_power is used in log.eval()).
There is a little graph of the dependencies of the modules in SymPy at
http://code.google.com/p/sympy/issues/detail?id=2103 (see the one from
comment 7). This may not be up to date, but I provide the code to
regenerate it.
You'll see from there that you will probably need to convert the polys
(this is almost as essential as the core for some operations), the
logic and assumptions modules, which are used for assumptions (I
wouldn't recommend trying to remove assumptions from the code), you'll
need the matrices and simplify for the solvers and integration modules
(and perhaps other things as well), and you might need some stuff from
utilities (which shouldn't cause too many problems with pyjamas, I
would think).
You can probably get rid of tensor by limiting the scope of which
functions you want to support.
If you just want to get Symbol('x') to work, you should start with
just the core, and work your way up from there. You can get a rough
idea of which modules are the most important by looking at what order
they are imported in sympy/__init__.py, since the ones that the others
depend on have to be imported first.
Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/sympy/-/jQKNmtFhCq4J.
Hi DennisSorry to revive an old thread, but I am also looking into compiling sympy to javascript (also only the basic math) - did you have success?
--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
Hi DennisSorry to revive an old thread, but I am also looking into compiling sympy to javascript (also only the basic math) - did you have success?
On Saturday, September 24, 2011 4:48:57 PM UTC+3, dennis wrote:
Dennis, is it possible to take a look at the result you get?I'm pretty interested in SymPy running at browser as well.Antony
воскресенье, 12 мая 2013 г., 19:21:12 UTC+3 пользователь dennis написал:
There's also the more speculative ideas of using Emscripten (example: http://repl.it/M4w) or Portable Native Client to compile the Python interpreter to JavaScript, then using that to run SymPy.
In Chrome, I get 0.555000066757; in Firefox I get 2.47399997711. I
also tried Safai 7.0.1 (I get 4.63800001144) and Opera because you
mentioned it (version 12.16, I get 4.44400000572).
So maybe Chrome beta already has some of the ASM stuff in it, but
whatever it is, it's clearly the fastest here.
For reference, when I run it in IPython in my terminal I get
0.0159571170807. So it's still 30 times slower.
@F.B. have you managed to compile Python using Emscripten? I tried but could not get the interpreter working, it just hung/crashed if I tried to bundle the standard library and complained about site.py otherwise.
Nuitka's aim is to be able to compile any python program to C++ and then to machine code. Nuitka's generated C++ code is independent of CPython, and thus has less boilerplate than running sympy inside a browser. I do not have much time, but if anyone is interested, that could be a nice experiment.