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

Nick Coghlan ncoghlan at gmail.com
Tue Mar 11 00:06:16 CET 2014


On 11 Mar 2014 01:20, "Steven D'Aprano" <steve at pearwood.info> wrote:
>
> 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.

I believe there were a few changes in how it interoperated with other
types, based on lessons learned from the module version (although I forget
the details).

Cheers,
Nick.

>
> 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
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140311/62b899d9/attachment.html>


More information about the Python-ideas mailing list