Brython 3.8.9 performance compared to CPython 3.8.0
User agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0
Test | Brython
(100 = CPython) | Code |
simple assignment | 66 |
- for i in range(1000000):
- a = 1
|
augmented assignment | 77 |
- a = 0
- for i in range(1000000):
- a += 1
|
simple assignment to float | 184 |
- for i in range(1000000):
- a = 1.0
|
big integers | 3659 |
- for i in range(100):
- 2 60
|
build dictionary | 318 |
- for i in range(1000000):
- a = {0: 0}
|
build dictionary 2 | 143 |
- d = {}
- for i in range(100000):
- d[i] = i
|
set dictionary item | 132 |
- a = {0: 0}
- for i in range(1000000):
- a[0] = i
|
build set | 625 |
- for i in range(1000000):
- a = {0, 2.7, "x"}
|
build list | 71 |
- for i in range(1000000):
- a = [1, 2, 3]
|
set list item | 98 |
- a = [0]
- for i in range(1000000):
- a[0] = i
|
integer addition | 196 |
- a, b, c = 1, 2, 3
- for i in range(1000000):
- a + b + c
|
string addition | 142 |
- a, b, c = 'a', 'b', 'c'
- for i in range(1000000):
- a + b + c
|
cast int to string | 127 |
- for i in range(100000):
- str(i)
|
create function without arguments | 446 |
- for i in range(1000000):
- def f():
- pass
|
create function, single positional argument | 464 |
- for i in range(1000000):
- def f(x):
- pass
|
create function, complex arguments | 655 |
- for i in range(1000000):
- def f(x, y=1, *args, kw):
- pass
|
function call | 804 |
- def f(x):
- return x
- for i in range(1000000):
- f(i)
|
function call, complex arguments | 1234 |
- def f(x, y=0, args, *kw):
- return x
- for i in range(100000):
- f(i, 5, 6, a=8)
|
create simple class | 498 |
- for i in range(10000):
- class A:
- pass
|
create class with init | 572 |
- for i in range(10000):
- class A:
- def init(self, x):
- self.x = x
|
create instance of simple class | 241 |
- class A:
- pass
-
- for i in range(1000000):
- A()
|
create instance of class with init | 1123 |
- class A:
- def init(self, x):
- self.x = x
-
- for i in range(100000):
- A(i)
|
call instance method | 2551 |
- class A:
- def init(self, x):
- self.x = x
-
- def f(self):
- return self.x
-
- a = A(1)
- for i in range(100000):
- a.f()
|