Skip to content

Commit 1828957

Browse files
author
hartsantler
committed
updated README.md, static types.
1 parent d534822 commit 1828957

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,29 @@ Example Projects
4141

4242
Speed
4343
---------------
44-
PythonJS allows you to select which features you need for
45-
each section of your code, where you need performance you
46-
can disable operator overloading, and other slow operations.
47-
Features can be switched off and on for blocks of code using
48-
`pythonjs.configure()` or the special `with` statements and
49-
decorators described below. When PythonJS is run in fastest
50-
mode (javascript mode) it beats native PyPy in the Richards, and N-Body benchmarks.
44+
PythonJS gives you the option to optimize your program for speed with a new syntax for static typing, in some cases this results in code that is 20X faster.
45+
A variable can be statically typed as: int, float, long, str, list, or dict.
46+
The translator then uses this type information to speed up runtime checks and method calls.
47+
In the example below `x` and `y` are typed as `int`.
48+
```
49+
def f(x,y):
50+
int x
51+
int y
52+
return x+y
53+
54+
```
55+
56+
The `int` type is accurate up to 53bits, if you need true 64bit integer math you can use the `long` type. Note using `long` requires the Long.js library.
57+
58+
You can further optimize your code with `pythonjs.configure` or special with statements that mark sections of the code as less dynamic.
5159

5260
N-Body benchmark
61+
5362
![nbody](http://2.bp.blogspot.com/-pylzspKRu6M/UqbAv3qIGTI/AAAAAAAAAkE/NnsAM5DZ_8M/s400/nbody.png)
5463

64+
more benchmarks
65+
66+
[http://pythonjs.blogspot.com/2014/05/pythonjs-now-faster-than-cpython.html](pystone, nbody, richards)
5567

5668

5769
translator.py

0 commit comments

Comments
 (0)