Skip to content

Commit

Permalink
Allow overriding level and pgc via env. Disable PGC by default
Browse files Browse the repository at this point in the history
  • Loading branch information
tonybaloney committed Dec 6, 2021
1 parent 6dfc965 commit c221b65
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ You can run ``pyjion`` as a standalone command-line program, similar to how you
optional arguments:
-m MODULE Execute module
You can enable PGC by setting the ``PYJION_PGC`` environment variable to 1.
You can override the optimization level (default 1) by setting the ``PYJION_LEVEL`` environment variable.

Core module
-----------

Expand Down
11 changes: 11 additions & 0 deletions src/pyjion/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import runpy
import pyjion
import sys
import os


def main():
Expand All @@ -12,6 +13,16 @@ def main():
)
exit(1)
pyjion.enable()
if 'PYJION_PGC' in os.environ:
pyjion.config(pgc=bool(os.environ['PYJION_PGC']))
else:
pyjion.config(pgc=False)

if 'PYJION_LEVEL' in os.environ:
pyjion.config(level=int(os.environ['PYJION_LEVEL']))
else:
pyjion.config(level=1)

if sys.argv[1] == "-m":
mod = sys.argv[2]
del sys.argv[1] # Drop -m
Expand Down

0 comments on commit c221b65

Please sign in to comment.