-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
CPython used for imported modules rather than byterun #26
Comments
I also just ran into this when trying to run byterun with itself. byterun.main is only imported once, then cached, so run_fn is only called the first time. it doesn't sound too hard to have a Module class, and replace import with a call to execfile or something similar.. is there a reason this hasn't been implemented yet? |
I would guess that if you want it implemented you should send a patch yourself. |
sure, but before I spend lots of time on such a thing, it would be nice to know if there is a particular reason for it not being implemented yet.. |
OK as far as I know the code I linked/quoted above fixes it. (I stopped working with this code some months ago and didn't get a response, so I didn't submit a patch.) |
Thanks for this great project -- I'm learning a lot from it. I'm using byterun as a test of a bigger project, and I found and fixed a bug:
oils-for-unix/oils@62cd492
There are some irrelevant diffs there, but if you search for BUG FIX you will see this part. The core issue is that the MAKE_FUNCTION bytecode is not called if you do
__import__
. byterun uses the host__import__
, which results in a native function, not apyobj.Function
. I also changed__repr__
ofFunction
to make this more apparent.Also of interest might be the speed tests at the end. I made two files:
speed_main.py
andspeed.py
. You will see that under byterun, using a function in library is much faster than using one in the same module, because it gets executed with CPython.If you are interested in a pull request, let me know. However I am highly confused about how you run
byterun/__main__.py
directly from the git repo with its relative imports? (and this is after 13 years of programming in Python, and being somewhat responsible for__main__.py
beiing added in Python 2.5 or 2.6).I guess you must either install it on the system or use some kind of wrapper? I think it is related to this:
http://stackoverflow.com/questions/11536764/how-to-fix-attempted-relative-import-in-non-package-even-with-init-py
I had to write a shell script wrapper than changed to the directory and used
python -m byterun.__main__
. Somehow changingPYTHONPATH
didn't work.The text was updated successfully, but these errors were encountered: