[Python-Dev] a new type for sys.implementation
Eric Snow
ericsnowcurrently at gmail.com
Fri Jun 1 18:17:10 CEST 2012
On Fri, Jun 1, 2012 at 7:17 AM, Mark Shannon <mark at hotpy.org> wrote:
> Previously you said that "it needs to handled in the implementation
> language, and explicitly *not* in Python".
> I asked why that was.
>
> Now you seem to be suggesting that Python code would break the DRY rule,
> but the C code would not. If the C code can avoid duplication, then so
> can the Python code, as follows:
>
> class SysImplementation:
>
> "Define __repr__(), etc here "
> ...
>
> import imp
> tag = imp.get_tag()
>
> sys.implementation = SysImplementation()
> sys.implementation.name = tag[:tag.index('-')]
> sys.implementation.version = sys.version_info
> sys.implementation.hexversion = sys.hexversion
> sys.implementation.cache_tag = tag
This was actually the big motivator for PEP 421. Once PEP 421 is
final, imp.get_tag() will get its value from sys.implementation,
rather than the other way around. The point is to pull the
implementation-specific values into one place (as much as is
reasonable).
-eric
More information about the Python-Dev
mailing list