[Python-ideas] Add additional special method lookups to math module

Jim Jewett jimjjewett at gmail.com
Thu Nov 10 03:17:53 CET 2011


On 11/9/11, Masklinn <masklinn at masklinn.net> wrote:
> On 2011-11-09, at 22:10 , Jeremy Sanders wrote:
>> Masklinn wrote:

>> If you go and change the behaviour of built-in functions just by importing
>> a  module it could lead to some weird bugs. I know monkey patching can
>> do this  currently, but doing it by default seems dangerous to me.
> Nothing in these two paragraphs makes any sense in the context of the
> current discussion. *Nobody* (but you) argues for "changing the behavior of
> built-in functions just by importing a module", or for "overriding a
> standard module".

Several people have suggested that the standard library module not be
changed, but that users be encouraged to monkeypatch instead.

In other words, if I import funkymathtype, it should (as part of the
import process) monkeypatch math (and cmath) to replace the builtin
functions with something that handles its own types as well.  Short of
generic functions, I happen to think that is a bad idea, but it was
suggested.

And frankly, "import funkymathtype.math as math" probably is the right
answer, in the short run, but that is still pretty fragile against
other modules having imported math themselves.

-jJ


-jJ



More information about the Python-ideas mailing list