Idiom for running compiled python scripts?
Mark
markbpan at mailinator.com
Fri Mar 23 03:30:58 EDT 2007
On Fri, 23 Mar 2007 14:03:12 +1100, Steven D'Aprano wrote:
> Since you've done these tests already, perhaps you can tell us what gain
> you actually got?
About the same as you, ~20 msecs for my small script samples.
> Of course you have to type the "c". You're not deleting the source files
> away are you? *wink*
Sorry, the wink is lost on me?
Of course I am not deleting the sources. In fact, I am also talking
about python scripts being called from shell scripts. I guess I'm just
surprised that the python installation does not provide a small stub
invoker, e.g:
A small script called "python_compile_and_run" in "pseudo" code:
#!/usr/bin/env python
import sys
# Following is invalid syntax unfortunately :(
from sys.argv[1].rstrip('.py') import main
sys.argv = sys.argv[1:]
if __name__ == "__main__":
main()
so I could just do a "python_compile_and_run myscript.py" and it would
do what I want, i.e. run myscript.pyc if available and valid, generate
and run it if necessary.
More information about the Python-list
mailing list