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

Robert Kern robert.kern at gmail.com
Mon Feb 2 22:08:51 CET 2009


On 2009-02-02 14:50, Nick Coghlan wrote:

Really drastic performance degradations would be on the radar as well - slowing pprint() down by 10% is unlikely to bother anyone, but slowing it down by 100% would be a bad thing (not that I think such a degradation is likely, I'm just trying to give an impression of the magnitude of change I'll be trying to measure).

Using the pretty module I referenced earlier, which basically uses simplegeneric's lookup algorithm:

In [11]: %timeit x=pprint.pformat(sys.modules) 10 loops, best of 3: 27.5 ms per loop

In [12]: %timeit x=pretty.pretty(sys.modules) 10 loops, best of 3: 39.9 ms per loop

In [13]: len(sys.modules) Out[13]: 517

The comparison is somewhat dodgy, though. pretty is not so much a refactoring of pprint as a reimplementation, so the time differences may not be due to the dispatch.

-- Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco



More information about the Python-Dev mailing list