Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #67208
| References | (9 earlier) <9f7b535f-9e5d-45df-96f6-6cd8f6b4a524@googlegroups.com> <530fff58$0$11113$c3e8da3@news.astraweb.com> <f5305bab-c526-420c-8590-d73ff318ee9c@googlegroups.com> <mailman.7454.1393563614.18130.python-list@python.org> <53103c03$0$11113$c3e8da3@news.astraweb.com> |
|---|---|
| Date | 2014-02-28 19:52 +1100 |
| Subject | Re: extend methods of decimal module |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.7461.1393577568.18130.python-list@python.org> (permalink) |
On Fri, Feb 28, 2014 at 6:34 PM, Steven D'Aprano <steve@pearwood.info> wrote: > On Fri, 28 Feb 2014 16:00:10 +1100, Chris Angelico wrote: > >> If we had some other tag, like 'd', we could actually construct a >> Decimal straight from the source code. Since source code is a string, >> it'll be constructed from that string, and it'll never go via float. > > Now that Python has a fast C implementation of Decimal, I would be happy > for Python 4000 to default to decimal floats, and require special syntax > for binary floats. Say, 0.1b if you want a binary float, and 0.1 for a > decimal. Maybe, but I believe the cdecimal module is still slower than typical floating point. There'd also be considerations regarding NumPy and how you'd go about working with an array of non-integer values, and so on. Certainly this will be an extremely reasonable topic of discussion once there's any notion of a Py4K on the cards. There'll be arguments on both sides. > But for now, backwards-compatibility requires that the default floating > point type remains binary float. But we could maybe agitate for a 1.234d > Decimal literal type. Care to write a PEP? > > :-) Heh. Strong consideration here: it would mean importing the decimal module on startup. >>> t=time.time(); import decimal; time.time()-t 4.5000159740448 >>> t=time.time(); import decimal; time.time()-t 0.0 A dummy import (when it's already loaded) is so fast that it's immeasurable, but four and a half seconds to load up decimal? This is 3.4.0b2 on Windows, btw. It was a lot quicker on my Linux box, probably because the OS or disk cache had the file. So maybe it wouldn't be too bad in practice; but it's still a cost to consider. >> The question is how far Python wants to bless the Decimal type with >> syntax - after all, if Decimal can get a literal notation, why can't >> Fraction, and why can't all sorts of other types? And that's a huge can >> of worms. > > I like Fractions, but I don't think they're important enough for the > average users to require literal notation. Yeah, but where do you draw the line? Either decimal.Decimal becomes a built-in type, or there needs to be a system for constructing literals of non-built-in types. And if Decimal becomes built-in, then why that and not <<insert type name here>>? Also, if Decimal becomes a built-in type, does that affect the numeric tower? ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
extend methods of decimal module "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-19 07:30 -0800
Re: extend methods of decimal module Terry Reedy <tjreedy@udel.edu> - 2014-02-19 13:59 -0500
Re: extend methods of decimal module "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-19 13:30 -0800
Re: extend methods of decimal module Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-02-19 15:54 -0600
Re: extend methods of decimal module Terry Reedy <tjreedy@udel.edu> - 2014-02-19 17:10 -0500
Re: extend methods of decimal module "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-27 04:07 -0800
Re: extend methods of decimal module Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-02-27 14:42 +0000
Re: extend methods of decimal module "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-27 07:42 -0800
Re: extend methods of decimal module Chris Angelico <rosuav@gmail.com> - 2014-02-28 02:57 +1100
Re: extend methods of decimal module Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-02-27 16:24 +0000
Re: extend methods of decimal module "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-27 15:00 -0800
Re: extend methods of decimal module Wolfgang <xpysol@gmail.com> - 2014-02-27 15:43 -0800
Re: extend methods of decimal module Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-02-27 23:50 +0000
Re: extend methods of decimal module "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-27 18:15 -0800
Re: extend methods of decimal module Chris Angelico <rosuav@gmail.com> - 2014-02-28 15:26 +1100
Re: extend methods of decimal module "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-27 21:18 -0800
Re: extend methods of decimal module Chris Angelico <rosuav@gmail.com> - 2014-02-28 16:26 +1100
Re: extend methods of decimal module Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2014-02-28 08:54 +0000
Re: extend methods of decimal module "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-28 10:23 -0800
Re: extend methods of decimal module Steven D'Aprano <steve@pearwood.info> - 2014-02-28 03:15 +0000
Re: extend methods of decimal module "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-27 20:41 -0800
Re: extend methods of decimal module Chris Angelico <rosuav@gmail.com> - 2014-02-28 16:00 +1100
Re: extend methods of decimal module Steven D'Aprano <steve@pearwood.info> - 2014-02-28 07:34 +0000
Re: extend methods of decimal module Chris Angelico <rosuav@gmail.com> - 2014-02-28 19:52 +1100
Re: extend methods of decimal module Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-28 15:11 +0000
Re: extend methods of decimal module Chris Angelico <rosuav@gmail.com> - 2014-03-01 02:36 +1100
Re: extend methods of decimal module "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-28 10:34 -0800
Re: extend methods of decimal module Chris Angelico <rosuav@gmail.com> - 2014-03-01 05:37 +1100
Re: extend methods of decimal module "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-28 11:26 -0800
Re: extend methods of decimal module "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-28 11:39 -0800
Re: extend methods of decimal module "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-28 12:17 -0800
Re: extend methods of decimal module Terry Reedy <tjreedy@udel.edu> - 2014-02-27 12:07 -0500
Re: extend methods of decimal module Anssi Saari <as@sci.fi> - 2014-03-01 08:55 +0200
Re: extend methods of decimal module "Mark H. Harris" <harrismh777@gmail.com> - 2014-03-01 16:49 -0800
Re: extend methods of decimal module Chris Angelico <rosuav@gmail.com> - 2014-02-28 04:48 +1100
Re: extend methods of decimal module Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-02-19 16:27 -0600
Re: extend methods of decimal module casevh@gmail.com - 2014-02-19 21:11 -0800
Re: extend methods of decimal module "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-27 02:33 -0800
Re: extend methods of decimal module casevh@gmail.com - 2014-02-28 06:23 -0800
Re: extend methods of decimal module Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-02-19 22:29 +0000
Re: extend methods of decimal module "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-27 02:37 -0800
csiph-web