numpy in Brython, anyone?

732 views
Skip to first unread message

Glenn Linderman

unread,
Aug 20, 2015, 12:20:01 AM8/20/15
to bry...@googlegroups.com
I recall there has been some discussion about Brython lacking numpy support in the past, although I didn't look for the postings.

I just stumbled across  https://hacks.mozilla.org/2014/10/introducing-simd-js/ which could be a building block for a numpy-compatible library for Brython, if and when someone gets motivated. I've no present need for numpy, but simd.js looks like interesting technology.

Glenn

Kiko

unread,
Aug 20, 2015, 2:05:12 AM8/20/15
to bry...@googlegroups.com
2015-08-20 6:19 GMT+02:00 Glenn Linderman <v+py...@g.nevcal.com>:
I recall there has been some discussion about Brython lacking numpy support in the past, although I didn't look for the postings.

I just stumbled across  https://hacks.mozilla.org/2014/10/introducing-simd-js/ which could be a building block for a numpy-compatible library for Brython, if and when someone gets motivated. I've no present need for numpy, but simd.js looks like interesting technology.


Well, numpy is not an easy one. Numpypy (numpy on pypy) is an effort of 4 years with money support behind, i.e., someone dedicated to it, and today is not finished...

Many dependencies on legacy code (C, C++, fortran,...).

There have been some efforts in the past in the js world:
https://github.com/search?utf8=%E2%9C%93&q=numpy+javascript (all of them are experiments or abandonware)
The most promising for me (numericjs, https://github.com/sloisel/numeric/commits/master) it seems is also abandoned.

Today, I think heavy computations should be done on the server side and the browser should show the results in an interactive way. Let's see tomorrow with all the crazyness around LLVM toolchain (http://cyrille.rossant.net/numpy-browser-llvm/) and wasm (web assembly) we could have good performance alà numpy in the browser...

 
Glenn

--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
To post to this group, send email to bry...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/55D55566.7060000%40g.nevcal.com.
For more options, visit https://groups.google.com/d/optout.

Billy Earney

unread,
Aug 20, 2015, 8:25:15 AM8/20/15
to bry...@googlegroups.com
I've always wondered if it would be best for us to create some type of wrapper/library/container gizmo for emscripten that would allow us to use the c/c++ libraries for things like numpy.   In the long run, it could save us a lot of work and headaches.   Any takers?

If no one is interested, eventually I might work on this.

Billy

Olemis Lang

unread,
Aug 20, 2015, 2:03:42 PM8/20/15
to bry...@googlegroups.com
On 8/20/15, Billy Earney <billy....@gmail.com> wrote:
> I've always wondered if it would be best for us to create some type of
> wrapper/library/container gizmo for emscripten that would allow us to use
> the c/c++ libraries for things like numpy. In the long run, it could save
> us a lot of work and headaches.

This seems to be a good idea but , IMO , to be developed in a separate
repository in brython-dev organisation .

[...]

--
Regards,

Olemis - @olemislc

Apache™ Bloodhound contributor
http://issues.apache.org/bloodhound
http://blood-hound.net

Brython committer
http://brython.info
http://github.com/brython-dev/brython

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:

Glenn Linderman

unread,
Aug 20, 2015, 2:41:05 PM8/20/15
to bry...@googlegroups.com
On 8/20/2015 11:03 AM, Olemis Lang wrote:
On 8/20/15, Billy Earney <billy....@gmail.com> wrote:
I've always wondered if it would be best for us to create some type of
wrapper/library/container gizmo for emscripten that would allow us to use
the c/c++ libraries for things like numpy.   In the long run, it could save
us a lot of work and headaches.
This seems to be a good idea but , IMO , to be developed in a separate
repository in brython-dev organisation .

[...]

I've only looked at a small amount of js code known to be compiled by emscripten. It wasn't at all clear even how to use it... but I only had to slightly tweak the code that was calling it. I suppose things would have been more clear if I had read the documentation for emscripten, and if I had the documentation for the original C source code as well... without such, it was quite an obscure mess. A Brython wrapper for emscripten-compiled libraries would seem to be useful. But one would likely need tho original C source code to create such. That is readily available, I would assume, for numpy.

Kiko

unread,
Aug 20, 2015, 3:34:21 PM8/20/15
to bry...@googlegroups.com
Hi, some thoughts about the topic:

-What would be the objective of the huge effort?
   Why wouild I like to do heavy calculation in the browser?
   In general, heavy computation needs heavy datasets. 
   Heavy datasets from a server?
   Heavy datasets from my computer?
   All these computations in the browser for what? 
   To obtain a final interactive figure?
-Most of the times browsers are blocked after some time running a js script doing some heavy computation.
-If you just want to have interactivity for your analyses to better understanding of the results, why not jupyter/IPython notebooks? There you have best of both worlds server with a kernel in python/Julia/R/Haskell,..., and a client with js/brython/coffeescript/..., to interact with the calculations from the kernel.
-If the IPython/Jupyter is enough you already have a brythonmagic to run brython there (https://github.com/kikocorreoso/brythonmagic). Once you have your nottebook you can share it with the world (interactive example not possible with the actual status of ipywidgets, http://nbviewer.ipython.org/github/kikocorreoso/brythonmagic/blob/master/notebooks/Most_popular_pypy_info.ipynb).

It is just that nowadays I don't see the benefit of a numpy in the browser. But  maybe I'm wrong... ;-D

--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
To post to this group, send email to bry...@googlegroups.com.

Glenn Linderman

unread,
Aug 20, 2015, 4:48:30 PM8/20/15
to bry...@googlegroups.com
On 8/20/2015 12:34 PM, Kiko wrote:
Hi, some thoughts about the topic:

-What would be the objective of the huge effort?
   Why wouild I like to do heavy calculation in the browser?
   In general, heavy computation needs heavy datasets. 
   Heavy datasets from a server?
   Heavy datasets from my computer?
   All these computations in the browser for what? 
   To obtain a final interactive figure?
-Most of the times browsers are blocked after some time running a js script doing some heavy computation.

As I stated at the outset, I have never discovered a need for numpy at all, much less in the browser. But there has been discussion about the lack of numpy on this list.

I've no clue how heavy a calculation must be, before it could benefit from numpy.  I've seen discussion on other lists about using numpy for graphics manipulation. Browsers are used for graphics manipulation. So maybe that is a "moderate" task that would benefit from numpy?


-If you just want to have interactivity for your analyses to better understanding of the results, why not jupyter/IPython notebooks? There you have best of both worlds server with a kernel in python/Julia/R/Haskell,..., and a client with js/brython/coffeescript/..., to interact with the calculations from the kernel.
-If the IPython/Jupyter is enough you already have a brythonmagic to run brython there (https://github.com/kikocorreoso/brythonmagic). Once you have your nottebook you can share it with the world (interactive example not possible with the actual status of ipywidgets, http://nbviewer.ipython.org/github/kikocorreoso/brythonmagic/blob/master/notebooks/Most_popular_pypy_info.ipynb).

So what web hosting companies offer jupyter support?



It is just that nowadays I don't see the benefit of a numpy in the browser. But  maybe I'm wrong... ;-D

Maybe you are right, maybe you are wrong, I wouldn't know.  simd.js just sounded like an interesting technology that could be used to rewrite numpy, or, with emscripten support as has been mentioned, to target when recompiling numpy via emscripten (once it supports simd.js).
Reply all
Reply to author
Forward
0 new messages