Test | Brython (100 = CPython) |
Code |
---|---|---|
simple assignment | 70 | for i in range(1000000): a = 1 |
augmented assignment | 50 | a = 0 for i in range(1000000): a += 1 |
augmented assignment and list append | 478 | t = [] i = 0 while i < 100000: t.append(i) i += 1 |
simple assignment to float | 59 | for i in range(1000000): a = 1.0 |
big integers | 284 | n = 60 for i in range(10000): 2 ** n |
hash string | 195 | for i in range(1000000): hash('abcdef') |
hash float | 144 | for i in range(1000000): hash(86.55) |
build dictionary | 313 | for i in range(1000000): a = {0: 0, 'a': 'a'} |
build dictionary 2 | 141 | d = {} for i in range(100000): d[i] = i |
set dictionary item | 177 | a = {0: 0} for i in range(1000000): a[0] = i |
build set | 649 | for i in range(1000000): a = {0, 2.7, "x"} |
build list | 36 | for i in range(1000000): a = [1, 2, 3] |
set list item | 62 | a = [0] for i in range(1000000): a[0] = i |
list slice | 159 | a = [1, 2, 3] for i in range(100000): a[:] |
integer addition | 55 | a, b, c = 1, 2, 3 for i in range(1000000): a + b + c |
integer + float | 43 | a, b = 1, 2.0 for i in range(1000000): a + b |
float addition | 58 | a, b = 1.0, 2.0 for i in range(1000000): a + b |
string addition | 44 | a, b, c = 'a', 'b', 'c' for i in range(1000000): a + b + c |
cast int to string | 133 | for i in range(100000): str(i) |
create function without arguments | 218 | for i in range(1000000): def f(): pass |
create function, single positional argument | 226 | for i in range(1000000): def f(x): pass |
create function, complex arguments | 229 | for i in range(1000000): def f(x, y=1, *args, **kw): pass |
function call | 267 | def f(x): return x for i in range(1000000): f(i) |
function call, complex arguments | 346 | def f(x, y=0, *args, **kw): return x for i in range(100000): f(i, 5, 6, a=8) |
create simple class | 595 | for i in range(10000): class A: pass |
create class with init | 592 | for i in range(10000): class A: def __init__(self, x): self.x = x |
create instance of simple class | 283 | class A: pass for i in range(1000000): A() |
create instance of class with init | 318 | class A: def __init__(self): pass for i in range(100000): A() |
call instance method | 445 | class A: def f(self): pass a = A() for i in range(100000): a.f() |
set instance attribute | 341 | class A: pass a = A() for i in range(100000): a.x = i |