Nick Coghlan wrote:
On Fri, Jun 1, 2012 at 9:49 PM, Mark Shannon <m...@hotpy.org> wrote:
What is wrong with something like the following (for CPython)?

class SysImplemention:
   "Define __repr__(), etc here "
   ...

sys.implementation = SysImplemention()
sys.implementation.name = 'cpython'
sys.implementation.version = (3, 3, 0, 'alpha', 4)
sys.implementation.hexversion = 0x30300a4
sys.implementation.cache_tag = 'cpython-33'

Because now you're double keying data in a completely unnecessary
fashion. The sys module initialisation code already has access to the
info needed to fill out sys.implementation correctly, moving that code
somewhere else purely for the sake of getting to write it in Python
instead of C would be foolish. Some things are best written in Python,
some make sense to write in the underlying implementation language.
This is one of the latter because it's all about implementation
details.

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

Cheers,
Mark.




_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to