[Python-ideas] Changing Decimal.__pos__ and Decimal.__neg__ [Was: Re: Python Numbers as Human Concept Decimal System]
random832 at fastmail.us
random832 at fastmail.us
Mon Mar 10 15:42:26 CET 2014
On Mon, Mar 10, 2014, at 10:21, Oscar Benjamin wrote:
> That's also possible. I wonder what a good name for a new Decimal type
> would be. It's unfortunate that calling it 'decimal' would sort of
> conflict with people doing 'import decimal'.
I don't think the conflict is a big deal. You can shadow builtins with
globals, and on the off chance that you want to use both, you can import
it as a different name. Any module that imports decimal is going to be
one that doesn't know or care about the built-in type.
To me, the more dicey aspect is what happens if you mix the types - if
you pick a type for mixed operations to convert to, then passing in the
'wrong' type will slowly 'infect' that module's data with a type which
has behavior subtly different from what it expects. You could disallow
mixed operations like it does now for floats, I suppose.
More information about the Python-ideas
mailing list