Pre-PEP: Dictionary accumulator methods

John Machin sjmachin at lexicon.net
Sat Mar 19 20:42:18 EST 2005


George Sakkis wrote:
> +1 on this. The new suggested operations are meaningful for a subset
of all valid dicts, so they
> should not be part of the base dict API. If any version of this is
approved, it will clearly be an
> application of the "practicality beats purity" zen rule, and the
justification for applying it in
> this case instead of subclassing should better be pretty strong; so
far I'm not convinced though.

My background: I've been subclassing dict since this was possible, to
provide not only a count/tally method but also a DIY intern method.
Before that I just copied dictmodule.c (every release!) and diffed and
hacked about till I had a mydict module.

*any* version? Could we make you happy by having a subclass
TotallySinfulDict provided as part of the core? You don't have to use
it -- come to think of it, you don't have to use a sinful method in the
base dict. You could even avert your gaze when reading the
documentation.

The justification for having it in the core: it's in C, not in Python,
it gets implemented and maintained (a) ONCE (b) by folk like the timbot
and Raymond instead of having (a) numerous versions lashed up (b) by
you and me and a whole bunch of n00bz and b1ffz :-)




More information about the Python-list mailing list