CPython on the Web

A

astar

Azakai/Gerry,


firefox 3.6.13 openbsd i386 4.8 -current
error console has some errors:

editor not defined
module not define
too much recursion

nothing interested happened on the web page, but wonderful project
anyway
 
A

azakai

A fun hack. Have you bothered to compare it to the PyPy javascript
backend - perfomance-wise, that is?

Gerry already gave a complete and accurate answer to the status of
this project in comparison to PyPy and pyjamas. Regarding performance,
this hack is not currently fast, primarily because the code is not
optimized yet.

But through a combination of optimizations on the side of Emscripten
(getting all LLVM optimizations to work when compiling to JS) and on
the side of the browsers (optimizing accesses on typed arrays in JS,
etc.), then I hope the code will eventually run quite fast, even
comparably to C.

- azakai
 
A

azakai

I tried printing sys.path and here is the output:
['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7/',
'/usr/local/lib/python2.7/plat-linux2',
'/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old',
'/usr/local/lib/lib-dynload']
Now, those paths must be on your machine because they are not on my
client machine.  But the interpreter is now running on MY machine.  Well
in a sandbox really.  So how is that going to work?
Yeah, those are the paths on the machine where the binary was compiled
(so, they are the standard paths on ubuntu).
Anyhow the filesystem can't (and shouldn't) be accessed from inside a
browser page.

Well, the local filesystem could be accessible with the user's
permission and this should be an option.

Hmm, I think this might be possible with the HTML5 File API. Would
definitely be useful here.

- azakai
 
M

MrJean1

FYI,

The example

http://syntensity.com/static/python.html

works fine in Safari 4.1.3 on MacOS X Tiger (10.4.11).

/Jean


On 01/03/2011 03:10 PM, azakai wrote:
I tried printing sys.path and here is the output:
['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7/',
'/usr/local/lib/python2.7/plat-linux2',
'/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old',
'/usr/local/lib/lib-dynload']
Now, those paths must be on your machine because they are not on my
client machine.  But the interpreter is now running on MY machine.  Well
in a sandbox really.  So how is that going to work?
Yeah, those are the paths on the machine where the binary was compiled
(so, they are the standard paths on ubuntu).
Anyhow the filesystem can't (and shouldn't) be accessed from inside a
browser page.
Well, the local filesystem could be accessible with the user's
permission and this should be an option.

Hmm, I think this might be possible with the HTML5 File API. Would
definitely be useful here.

- azakai
 
J

John Nagle

Hello, I hope this will be interesting to people here: CPython running
on the web,

http://syntensity.com/static/python.html

That isn't a new implementation of Python, but rather CPython 2.7.1,
compiled from C to JavaScript using Emscripten and LLVM. For more
details on the conversion process, see http://emscripten.org

It's a cute hack, but it's about 1000 times slower than CPython.

Try

def cnt(n) :
j = 0
for i in xrange(n) :
j = j + 1
return(j)

print(cnt(1000000))

with this. It will take 30 seconds or so to count to a million.

John Nagle
 
A

azakai

    It's a cute hack, but it's about 1000 times slower than CPython.

Try

def cnt(n) :
     j = 0
     for i in xrange(n) :
         j = j + 1
     return(j)

print(cnt(1000000))

with this.  It will take 30 seconds or so to count to a million.

                                        John Nagle

Yes, as I said, "the code isn't optimized (so
don't expect good performance)" :)

It can get much faster with more work.

- azakai
 
J

John Nagle

Yes, as I said, "the code isn't optimized (so
don't expect good performance)" :)

It can get much faster with more work.

Yea, right.

You're three deep in interpreters. Performance is going
to suck.

John Nagle
 
C

Carl Banks

But through a combination of optimizations on the side of Emscripten
(getting all LLVM optimizations to work when compiling to JS) and on
the side of the browsers (optimizing accesses on typed arrays in JS,
etc.), then I hope the code will eventually run quite fast, even
comparably to C.

This is a very cool idea. It's quite fascinating to view the
Javascript "machine code" for a complete CPython interpreter.

I'm sure with a little work you'll be able to improve its performance,
but I think "comparably to C" is going to be a tall order.

If you can get this to work reasonably well, and manage to get it
successfully deployed it somewhere, I'd recommend petitioning to have
this be considered an official platform.


Carl Banks
 
G

gry

On loading, I "get script stack space quota is exhausted" under
firefox 3.5.12, under linux.
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12) Gecko/20100907
Fedora/3.5.12-1.fc12 Firefox/3.5.12
 
G

Gerry Reno

On loading, I "get script stack space quota is exhausted" under
firefox 3.5.12, under linux.
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12) Gecko/20100907
Fedora/3.5.12-1.fc12 Firefox/3.5.12


It's a Firefox bug apparently fixed in Firefox 4.x.

Some versions of Firefox 3.6.x do work but most do not.


Regards,
Gerry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top