8000 __file__ returns differnet filenames · Issue #363 · jython/jython · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

__file__ returns differnet filenames #363

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

Open
HahnloserR opened this issue Dec 2, 2024 · 3 comments
Open

__file__ returns differnet filenames #363

HahnloserR opened this issue Dec 2, 2024 · 3 comments

Comments

@HahnloserR
Copy link
HahnloserR commented Dec 2, 2024

when a jython script runs for the first time, file returns the source filename.

while running the script another time, file returns the name of the bytecode file.

Shouldn't it return the sourcefilename all the time? Is there a parameter to change the behaviour?

The behaviour seems to be changed with the update from V2.7.2 to V2.74.

@jeff5
Copy link
Member
jeff5 commented Dec 3, 2024

I don't observe this in tests.

PS 363> jython -V
Jython 2.7.4
PS 363> cat filename.py
print __file__
PS 363> jython filename.py
filename.py
PS 363> jython filename.py
filename.py

If you import a module, then yes it makes a compiled file and reads it the second time, but so does CPython.

PS 363> jython -c"import filename"
filename.py
PS 363> jython -c"import filename"
filename$py.class
PS 363> python -c"import filename"
filename.py
PS 363> python -c"import filename"
filename.pyc

It may have changed since 2.7.2. We're always fixing things. :)

@HahnloserR
Copy link
Author

Sorry, you're absolutely right, I was talking about an imported module.

I helped myself by disabling the generation of bytecode.
Is there a significant difference in execution time using bytecode or not?

@jeff5
Copy link
Member
jeff5 commented Dec 6, 2024

I don't have any figures, and only the obvious to point out, that it does the compilation again.

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

2 participants
0