Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexcepted results when enabling jit #524

Open
Mskxn opened this issue Jun 25, 2024 · 2 comments
Open

Unexcepted results when enabling jit #524

Mskxn opened this issue Jun 25, 2024 · 2 comments

Comments

@Mskxn
Copy link

Mskxn commented Jun 25, 2024

version:
pyjion 2.0.0 (compile with latest source code)
ubuntu 20.04
python 3.10.12

This code behavior is different when enabling jit, x.fn = lambda x, y: x + y seems be ignored:

class A:
    def __init__(self):
        pass

    def fn(self, x, y):
        return x * y

def f(x, y):
    return x.fn(y, y)

for i in range(10000):
    x = A()
    r = f(x, i)

x.fn = lambda x, y: x + y
r = f(x, 1)
print(r)
# excepted 2 but 1
@Mskxn
Copy link
Author

Mskxn commented Jul 16, 2024

version:
pyjion 2.0.0 (compile with latest source code)
ubuntu 20.04
python 3.10.12

This code triggers a crash instead of something like a cold exit.

import pyjion; pyjion.enable()

def compare(a, b):
    return a + b - b

for i in range(100000):
    r = compare(1.1, 1.1)

r = compare(1, 1.1)
print(r)

"""
Traceback (most recent call last):
  File "/root/work/src/temp.py", line 9, in <module>
    r = compare(1, 1.1)
  File "/root/work/src/temp.py", line 4, in compare
    return a + b - b
pyjion.PyjionUnboxingError: Optimizations are invalid. Pyjion PGC expected float, but 1 is a int. Try disabling PGC pyjion.config(pgc=False) or lowering the optimization level to avoid hitting this error.
"""

@Mskxn
Copy link
Author

Mskxn commented Jul 16, 2024

The following code returns 0 instead of UnboundLocalError:

import pyjion; pyjion.enable()

def f():
    it = range(0)
    for i in it:
        pass
    return i

r = f()
print(r)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant