[Python-Dev] pprint(iterator) (original) (raw)

Paul Moore p.f.moore at gmail.com
Mon Feb 2 11:43:22 CET 2009


2009/2/2 Nick Coghlan <ncoghlan at gmail.com>:

A trio of patches that: 1. promoted simplegeneric from pkgutil to functools (with appropriate documentation and tests) 2. changed pkgutil to use functools.simplegeneric instead of its current internal version 3. updated pprint to be a generic function (and hence more easily extensible via the ABC mechanism, while still keeping it's current special cases as necessary)

would certainly be an interesting thing to see (with patch 3 being the poster child for why patch 1 is a good idea).

I'll see what I can do. I can't promise much for (3) as I don't personally have a need for it, so my understanding of the use cases is limited at best. But (1) and (2) should be possible.

Can I assign the patches to you (for review, at least)?

The major virtue of such a basic generic framework is that it is much easier to explain than the all-singing all-dancing overloading system described in PEP 3124. Type-based dispatch on the first argument is fairly straightforward to describe in terms that make sense to anyone that is already familiar with dynamic dispatch of class and instance methods. It's only when you get into more exotic dispatch conditions and up-calls and the like that people's eyes start to glaze over.

Agreed. And given that the simple case probably covers 90% of the practical requirements, that's a shame.

Paul.



More information about the Python-Dev mailing list