[Python-Dev] a new type for sys.implementation (original) (raw)
Eric Snow ericsnowcurrently at gmail.com
Thu May 31 09:21:36 CEST 2012
- Previous message: [Python-Dev] [Python-checkins] cpython: Make parameterized tests in email less hackish.
- Next message: [Python-Dev] a new type for sys.implementation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
The implementation for sys.implementation is going to use a new (but "private") type[1]. It's basically equivalent to the following:
class namespace: def init(self, **kwargs): self.dict.update(kwargs) def repr(self): keys = (k for k in self.dict if not k.startswith('_')) pairs = ("{}={!r}".format(k, self.dict[k]) for k in sorted(keys)) return "{}({})".format(type(self).name, ", ".join(pairs))
There were other options for the type, but the new type was the best fit and not hard to do. Neither the type nor its API is directly exposed publicly, but it is still accessible through "type(sys.implementation)".
This brings me to a couple of questions:
- should we make the new type un-instantiable (null out tp_new and tp_init)?
- would it be feasible to officially add the type (or something like it) in 3.3 or 3.4?
I've had quite a bit of positive feedback on the type (otherwise I wouldn't bother bringing it up). But, if we don't add a type like this to Python, I'd rather close the loophole and call it good (i.e. not introduce a new type by stealth). My preference is for the type (or equivalent) to be blessed in the language. Regardless of the specific details of such a type, my more immediate concern is with the impact on sys.implementation of python-dev's general sentiment in this space.
-eric
[1] http://bugs.python.org/issue14673
- Previous message: [Python-Dev] [Python-checkins] cpython: Make parameterized tests in email less hackish.
- Next message: [Python-Dev] a new type for sys.implementation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]