This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Python needs a way to detect implementation
Type: enhancement Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: kayhayen2, loewis
Priority: normal Keywords:

Created on 2007-02-27 07:32 by kayhayen2, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg31381 - (view) Author: Kay Hayen (kayhayen2) Date: 2007-02-27 07:32
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
msg31382 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-03-01 06:40
Please take a look at sys.subversion. This is fixed in Python 2.5.
msg31383 - (view) Author: Kay Hayen (kayhayen2) Date: 2007-03-01 18:01
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?



msg31384 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-03-01 21:40
No; it should be only available in Python implementations that do indeed have subversion information available.

If you truly want something that all Python implementations must implement to be valid implementations of the Python programming language, you will have to write a PEP.

Closing this as "works for me".
History
Date User Action Args
2022-04-11 14:56:22adminsetgithub: 44631
2007-02-27 07:32:52kayhayen2create