Issue 1669743: Python needs a way to detect implementation (original) (raw)

Hello,

I am currently writing an application that will run under both CPython and PyPy. In this I encountered the need to discover the implementation of the current interpreter.

For example, with PyPy the use of StringIO may offer benefits due to the possibility of more complete analysis of data flows during compilation or JIT execution. I want to take advantage of this. (Granted, currently pypy will run on top of CPython most of the time, so it's not the real solution to my problem until PyPy-c is at comparable performance). This is only example, a lot of different performance behaviors exist, that at times, will make sense to be abstracted.

I have checked module sys of both implementations (plus Jython) and found in CPython only the property "subversion", which contains a tuple with CPython being the first element. My suspect is though that this is related to the detail of using svn in CPython development, and as such, would not be a good standard.

So, what I believe with more and more Python versions existing (e.g. IronPython), it is needed to have sys.implementation that puts sys.version into context. My proposal is that CPython leads the effort to aid this, and the other Python variants can then adopt the standard property.

Thank you in advance, Kay Hayen

Well, I did find sys.subversion of CPython 2.5 and sys.pypy_svn_url of Pypy 0.99 or so.

The docs currently say about sys.subversion:

"A triple (repo, branch, version) representing the Subversion information of the Python interpreter. repo is the name of the repository, 'CPython'. branch is a string of one of the forms 'trunk', 'branches/name' or 'tags/name'. version is the output of svnversion [...]"

Would you confirm that sys.subversion is a property that every implementation of Python should have?