Message312444
StringTranslatePseudoMapping (Mapping) is an awkward and not very descriptive name. It is similar to collections.defaultdict except that it uses a default value rather than a default factory. The latter is so defaults can be mutables. Would a subclass of similar to defaultdict be faster?
Unlike, defaultdict, the initialized default is used in get as well as __getitem__. This means that STPM.get ignores a passed-in default, contrary to the definition of Mapping.get. The method override is not needed.
The internal self._get is only needed because it is called in both __getitem__ and get. Without the get override, it's body (with 'self.' added, can become the body of __getitem__. I suspect that this would make __getitem__ faster. Test this. |
|
Date |
User |
Action |
Args |
2018-02-20 23:33:06 | terry.reedy | set | recipients:
+ terry.reedy, cheryl.sabella |
2018-02-20 23:33:06 | terry.reedy | set | messageid: <1519169586.6.0.467229070634.issue32880@psf.upfronthosting.co.za> |
2018-02-20 23:33:06 | terry.reedy | link | issue32880 messages |
2018-02-20 23:33:06 | terry.reedy | create | |
|