[Python-3000] PEP: Cleaning out sys and the "interpreter" module
musiccomposition at gmail.com
Mon Apr 7 23:10:01 CEST 2008
After a long conversation on the stdlib-sig list, I'd like to bring this
before you. For those of you not on the peps mailing list, Guido has
expressed lukewarmness (well -0.5) to the idea. However, I'd still like your
comments on my first PEP.
Title: Cleaning out sys and the "interpreter" module
Author: Benjamin Peterson
Type: Standards Track
This PEP proposes a new low-level module for CPython-specific interpreter
functions in order to clean out the sys module and separate general Python
functionality from implementation details.
The sys module currently contains functions and data that can be put into
1. Data and functions that are available in all Python implementations and
with the general running of a Python virtual machine.
- path, path_hooks, meta_path, path_importer_cache, and modules
- copyright, hexversion, version, and version_info
- displayhook, __displayhook__
- excepthook, __excepthook__, exc_info, and exc_clear
- exec_prefix and prefix
- flags, py3kwarning, dont_write_bytecode, and warn_options
- get/settrace, call_tracing
- maxint and maxunicode
- ps1 and ps2
- stdin, stderr, stdout, __stdin__, __stderr__, __stdout__
2. Data and functions that affect the CPython interpreter.
- _getframe and _current_frame
The second collections of items has been steadily increasing over the years
causing clutter in sys. Guido has even said he doesn't recognize some of
in it [#bug-1522]_!
Other implementations have clearly struggled with what to do about the
of sys they can't implement but must to retain compatibility. For example,
Jython's sys module has dud set/getrecursionlimit functions. Moving these
items off to another module would send a clear message about what functions
and need not be implemented.
It has also been proposed that the contents of types module be distributed
across the standard library [#types-removal]_; the interpreter module would
provide an excellent resting place for internal types like frames and code
A new builtin module named "interpreter" (see `Naming`_) will be added.
The second list of items above will be split into the stdlib as follows:
The interpreter module
- _getframe and _current_frame
The gc module:
Once implemented in 3.x, the interpreter module will be back-ported to 2.6.
Py3k warnings will be added the the sys functions it replaces.
What should move?
Some believe that the writing of bytecode is an implementation detail and
be moved [#bytecode-issue]_. The counterargument is that all current,
Python implementations do write some sort of bytecode, so it is valuable to
able to disable it. Also, if it is moved, some wish to put it in the imp
Move to some to imp?
It was noted that dont_write_bytecode or maybe builtin_module_names might
nicely in the imp module.
The author proposes the name "interpreter" for the new module. "pyvm" has
been suggested [#pyvm-name]_. The name "cpython" was well liked
This document has been placed in the public domain.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-3000