Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upCPython used for imported modules rather than byterun #26
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
srepmub
Oct 17, 2017
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?
srepmub
commented
Oct 17, 2017
|
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? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
andychu
Oct 17, 2017
I would guess that if you want it implemented you should send a patch yourself.
andychu
commented
Oct 17, 2017
|
I would guess that if you want it implemented you should send a patch yourself. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
srepmub
Oct 19, 2017
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..
srepmub
commented
Oct 19, 2017
|
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.. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
andychu
Oct 19, 2017
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.)
andychu
commented
Oct 19, 2017
|
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.) |
andychu commentedApr 17, 2017
•
edited
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:
oilshell/oil@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__ofFunctionto make this more apparent.Also of interest might be the speed tests at the end. I made two files:
speed_main.pyandspeed.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__.pydirectly from the git repo with its relative imports? (and this is after 13 years of programming in Python, and being somewhat responsible for__main__.pybeiing 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 changingPYTHONPATHdidn't work.