[Python-ideas] Changing Decimal.__pos__ and Decimal.__neg__ [Was: Re: Python Numbers as Human Concept Decimal System]

Steven D'Aprano steve at pearwood.info
Mon Mar 10 16:19:23 CET 2014


On Mon, Mar 10, 2014 at 09:55:09AM -0400, random832 at fastmail.us wrote:
> On Mon, Mar 10, 2014, at 9:30, Mark Dickinson wrote:
> > I guess I have ulterior motives; (ab)using '+' to mean 'round to the
> > current context' has always felt way too implicit for my tastes, and I'd
> > jump at the chance to see it go away.
> 
> It occurs to me that there is an unprecedented opportunity to make warts
> "go away" - making Decimal a "first-class citizen" suggests moving it
> from the decimal module to a built-in type. Any backwards-incompatible
> change you want to make, you can give programs importing decimal the old
> behavior, and reserve the new behavior for the new type in builtins.

Historically, I don't think Python has changed the API for types when 
they've moved from a module to a built-in. I can't think of any example 
except set, but apart from a change in name from set.Set to set, I don't 
think there were any changes.

Any other precedents?

On the other hand, the built-in doesn't need to be a replacement for the 
decimal module, but rather an alternative solution. If decimal64 was a 
built-in, presumably it wouldn't need contexts and would be a lot 
simpler. The decimal module would still be available for those with 
advanced needs.


-- 
Steven


More information about the Python-ideas mailing list