Brython 3.13.0 performance compared to CPython 3.13.0

User agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
10/10/2024 11:37

Test Brython
(100 = CPython)
Code
simple assignment63
for i in range(1000000):
    a = 1
augmented assignment50
a = 0
for i in range(1000000):
    a += 1
augmented assignment and list append408
t = []
i = 0
while i < 100000:
    t.append(i)
    i += 1
simple assignment to float99
for i in range(1000000):
    a = 1.0
big integers249
n = 60
for i in range(10000):
    2 ** n
hash string234
for i in range(1000000):
    hash('abcdef')
hash float179
for i in range(1000000):
    hash(86.55)
build dictionary385
for i in range(1000000):
    a = {0: 0, 'a': 'a'}
build dictionary 2120
d = {}
for i in range(100000):
    d[i] = i
set dictionary item240
a = {0: 0}
for i in range(1000000):
    a[0] = i
build set1069
for i in range(1000000):
    a = {0, 2.7, "x"}
build list63
for i in range(1000000):
    a = [1, 2, 3]
set list item108
a = [0]
for i in range(1000000):
    a[0] = i
list slice191
a = [1, 2, 3]
for i in range(100000):
    a[:]
integer addition67
a, b, c = 1, 2, 3
for i in range(1000000):
    a + b + c
integer + float78
a, b = 1, 2.0
for i in range(1000000):
    a + b
float addition98
a, b = 1.0, 2.0
for i in range(1000000):
    a + b
string addition63
a, b, c = 'a', 'b', 'c'
for i in range(1000000):
    a + b + c
cast int to string170
for i in range(100000):
    str(i)
create function without arguments189
for i in range(1000000):
    def f():
        pass
create function, single positional argument191
for i in range(1000000):
    def f(x):
        pass
create function, complex arguments183
for i in range(1000000):
    def f(x, y=1, *args, **kw):
        pass
function call327
def f(x):
    return x
for i in range(1000000):
    f(i)
function call, complex arguments313
def f(x, y=0, *args, **kw):
    return x
for i in range(100000):
    f(i, 5, 6, a=8)
create simple class429
for i in range(10000):
    class A:
        pass
create class with init305
for i in range(10000):
    class A:
        def __init__(self, x):
            self.x = x
create instance of simple class851
class A:
    pass

for i in range(1000000):
    A()
create instance of class with init703
class A:
    def __init__(self):
        pass

for i in range(100000):
    A()
call instance method520
class A:
    
    def f(self):
        pass

a = A()
for i in range(100000):
    a.f()
set instance attribute429
class A:
    pass

a = A()
for i in range(100000):
    a.x = i