OpenVMS Source Code Demos

Python JIT Compiler

1) the following information applies to all implementations of python3 on all systems
2) on OpenVMS systems: directory definitions are wrapped with square brackets
3) the PVM (python virtual machine) used here is cpython-310 (an implementation of python 3.10.0 written in C)
4) imported libraries are always case sensitive
5) file extensions:
py (python source code)
pyc (python compiled)

edit: 2023-08-20

How it is supposed to work:

  • Directly invoke python script
    • the script is compiled to bytecode in memory which is then executed via the PVM (python virtual machine)
    • the bytecode is discarded when the PVM exits
  • Indirectly invoke python script
    execute this DCL command python start
    "import hello_world" looks for source file
    look at timestamp of file
    look for subfolder [.__pycache__]
    look for bytecode file [.__pycache__]hello_world.cpython-310.pyc
    compare timestamps
    if pyc is after py then run


    stop 1
    compile py script then saves pyc [.__pycache__]hello_world.cpython-310.pyc
    (could result in the creation of a sub folder)

    python executes [.__pycache__]hello_world.cpython-310.pyc stop 2
  • Notice that the PVM version name is combined with the source code name when writing the bytecode file. If the Python PVM is updated then this JIT process would automatically compile and save new bytecode files using the new version name.

Python-3.10.0 on OpenVMS-8.4

  • I have noticed an intermittent problem with the python3-10.0 implementation on OpenVMS because executing causes a newly compiled version of [.__pycache__]hello_world.cpython-310.pyc to be generated during each execution. Doing it this way would actually be a slowdown rather than a speedup.
  • Solution:
    • this only happens with original scripts created with either the EDT or EVE editors which produce variable-length RMS text records
    • if the scripts were created with either the VI or VIM editors, or copied via SFTP from a Linux system, then the files will be in stream-LF format which caused the problem to disappear. The following procedure can be used to create a new file with the desired properties.
      ! first we need a foreign command
      $ rfmstmlf :== convert/fdl="""record; format stream_lf"""
      ! now we use the foreign command to convert the file to stream_lf
      $ rfmstmlf targetfile.txt
# ======================================================
# title   :
# platform: OpenVMS-8.4-1H1 I64 (Itanium)
# author  : Neil Rieck
# created : 2023-08-08 # usage : python # ====================================================== import hello_world hello_world.main()

# ======================================================
# title   :
# platform: OpenVMS-8.4-1H1 I64 (Itanium)
# author  : Neil Rieck
# created : 2023-08-08 # usage : # 1) python (compiles to memory every time) # 2) import then run from another script # note: see '' in this folder # ====================================================== def main(): print("hello world") if __name__ == "__main__": main()