Python's simplicity philosophy

Tim Peters tim.one at comcast.net
Sat Nov 15 03:58:53 EST 2003


[Andrew Dalke]
> There's also a __reduce__ and __reduce_ex__ in the pickle
> protocol.  See  http://www.python.org/peps/pep-0307.html .
> It's by far the most mentioned 'reduce' in the Python standard
> library.  Does it have anything to do with the 'reduce' function?
> Not that I can tell.

It doesn't -- reduce() and __reduce__() have no intersection.

> But I can't find an explaination for that choice of a name.

Well, this comes from the tradition that thought it made good sense to call
a serialized object representation "a pickle".  Applying the same kind of
real-life common sense, what do you call the act of changing a real-world
object, like a refrigerator or a wide-screen plasma TV, into a string, a
(function, args) tuple, or a (function, args, state) tuple sufficient to
reproduce the fridge or TV?  Of course everyone calls that "reducing the
refrigerator" or "reduce_exing the wide-screen plasma TV".  Hence the kind
of people who thought "pickle" was a good name also thought it was a good
idea to stick underscores around "reduce" and "reduce_ex" <wink>.

Possibly more likely is that they knew they wouldn't remember how to spell
__cerealeyes__.  Give a pro a reduce and he can re-pro-duce.






More information about the Python-list mailing list