Re: [Python-Dev] PEP 0484 - the Numeric Tower

2015-10-13 Thread Chris Barker - NOAA Federal
I merely worry about what happens if people > start relying upon the fact that a float annotation 'will handle all > the numbers I care about' to the forgotten Decimal users such as > myself. Well, that's what you get in exchange for "type safety". Which is exactly why I'm concerned about

[Python-Dev] PEP 0484 - the Numeric Tower

2015-10-13 Thread Laura Creighton
Any chance of adding Decimal to the list of things that are also acceptable for things annotated float? Laura ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe:

[Python-Dev] Rationale behind lazy map/filter

2015-10-13 Thread Stefan Mihaila
Hey guys, Could someone clarify for me why it is a good idea to have map return an iterator that is iterable multiple times and acts as an empty iterator in subsequent iterations? > r = range(10) > list(r) == list(r) True > a=map(lambda x:x+1, [1,2,3]) > list(a) == list(a) False Wouldn't it

Re: [Python-Dev] Rationale behind lazy map/filter

2015-10-13 Thread R. David Murray
On Tue, 13 Oct 2015 14:59:56 +0300, Stefan Mihaila wrote: > Maybe it's just python2 habits, but I assume I'm not the only one > carelessly thinking that "iterating over an input a second time will > result in the same thing as the first time (or raise an error)".

Re: [Python-Dev] Rationale behind lazy map/filter

2015-10-13 Thread Random832
"R. David Murray" writes: > On Tue, 13 Oct 2015 14:59:56 +0300, Stefan Mihaila > wrote: >> Maybe it's just python2 habits, but I assume I'm not the only one >> carelessly thinking that "iterating over an input a second time will >> result in

Re: [Python-Dev] PEP 0484 - the Numeric Tower

2015-10-13 Thread Raymond Hettinger
> On Oct 13, 2015, at 4:21 AM, Laura Creighton wrote: > > Any chance of adding Decimal to the list of things that are also > acceptable for things annotated float? >From Lib/numbers.py: ## Notes on Decimal ## ## Decimal has all of the methods specified by the

Re: [Python-Dev] Rationale behind lazy map/filter

2015-10-13 Thread Zachary Ware
On Tue, Oct 13, 2015 at 10:26 AM, Random832 wrote: > "R. David Murray" writes: > >> On Tue, 13 Oct 2015 14:59:56 +0300, Stefan Mihaila >> wrote: >>> Maybe it's just python2 habits, but I assume I'm not the only one >>>

Re: [Python-Dev] Rationale behind lazy map/filter

2015-10-13 Thread R. David Murray
On Tue, 13 Oct 2015 11:26:09 -0400, Random832 wrote: > "R. David Murray" writes: > > > On Tue, 13 Oct 2015 14:59:56 +0300, Stefan Mihaila > > wrote: > >> Maybe it's just python2 habits, but I assume I'm not the only one

Re: [Python-Dev] Rationale behind lazy map/filter

2015-10-13 Thread Random832
"R. David Murray" writes: > On Tue, 13 Oct 2015 11:26:09 -0400, Random832 wrote: >> It does raise the question though of what working code it would actually >> break to have "exhausted" iterators raise an error if you try to iterate >> them again

Re: [Python-Dev] PEP 0484 - the Numeric Tower

2015-10-13 Thread Laura Creighton
In a message of Tue, 13 Oct 2015 08:38:07 -0700, Raymond Hettinger writes: > > >> On Oct 13, 2015, at 4:21 AM, Laura Creighton wrote: >> >> Any chance of adding Decimal to the list of things that are also >> acceptable for things annotated float? > >>From Lib/numbers.py: > >##

Re: [Python-Dev] Rationale behind lazy map/filter

2015-10-13 Thread Chris Angelico
On Wed, Oct 14, 2015 at 3:49 AM, Random832 wrote: > My theory is that most circumstances under which this would cause a > RuntimeError are indicative of a bug in the algorithm consuming the > iterator (for example, an algorithm that hasn't considered iterators and >

Re: [Python-Dev] Rationale behind lazy map/filter

2015-10-13 Thread Chris Angelico
On Wed, Oct 14, 2015 at 3:08 AM, Random832 wrote: > If you are writing code that tries > to resume iterating after the iterator has been exhausted, I have to > ask: why? A well-behaved iterator is supposed to continue raising StopIteration forever once it's been

Re: [Python-Dev] PEP 0484 - the Numeric Tower

2015-10-13 Thread Random832
> From Lib/numbers.py: > > ## Notes on Decimal > ## > ## Decimal has all of the methods specified by the Real abc, but it should > ## not be registered as a Real because decimals do not interoperate with > ## binary floats (i.e. Decimal('3.14') + 2.71828 is undefined). But, > ##

Re: [Python-Dev] Rationale behind lazy map/filter

2015-10-13 Thread Random832
Chris Angelico writes: > A well-behaved iterator is supposed to continue raising StopIteration > forever once it's been exhausted. Yes, and that is *precisely* the behavior that causes the problem under discussion. My question was what code depends on this. > Play with that,

Re: [Python-Dev] Rationale behind lazy map/filter

2015-10-13 Thread Chris Jerdonek
On Tue, Oct 13, 2015 at 8:26 AM, Random832 wrote: > "R. David Murray" writes: > >> On Tue, 13 Oct 2015 14:59:56 +0300, Stefan Mihaila >> wrote: >>> Maybe it's just python2 habits, but I assume I'm not the only one >>>

Re: [Python-Dev] Rationale behind lazy map/filter

2015-10-13 Thread R. David Murray
On Tue, 13 Oct 2015 12:08:12 -0400, Random832 wrote: > "R. David Murray" writes: > > On Tue, 13 Oct 2015 11:26:09 -0400, Random832 > > wrote: > > > > And the answer to the question is: lots of code. I've written some: > >

Re: [Python-Dev] PEP 0484 - the Numeric Tower

2015-10-13 Thread Sven R. Kunze
On 13.10.2015 17:38, Raymond Hettinger wrote: Traceback (most recent call last): File "", line 1, in Decimal('3.14') + 2.71828 TypeError: unsupported operand type(s) for +: 'decimal.Decimal' and 'float' Reminds me of 'int' and 'long'. Different but almost the same. Best,

Re: [Python-Dev] PEP 0484 - the Numeric Tower

2015-10-13 Thread Random832
Steven D'Aprano writes: > On Tue, Oct 13, 2015 at 04:37:43PM -0700, Raymond Hettinger wrote: > >> We could have (and still could) make the choice to always coerce to >> decimal (every float is exactly representable in decimal). Further, >> any decimal float or binary

Re: [Python-Dev] Rationale behind lazy map/filter

2015-10-13 Thread Terry Reedy
On 10/13/2015 7:59 AM, Stefan Mihaila wrote: Could someone clarify for me ... This list, pydev, short for 'python development', is for discussing development of future releases of CPython. Your question should have been directed to python-list, where it would be entirely on topic. --

Re: [Python-Dev] PEP 0484 - the Numeric Tower

2015-10-13 Thread Steven D'Aprano
On Tue, Oct 13, 2015 at 04:37:43PM -0700, Raymond Hettinger wrote: > We could have (and still could) make the choice to always coerce to > decimal (every float is exactly representable in decimal). Further, > any decimal float or binary float could be losslessly coerced to a > Fraction, but

Re: [Python-Dev] Rationale behind lazy map/filter

2015-10-13 Thread Steven D'Aprano
On Tue, Oct 13, 2015 at 11:26:09AM -0400, Random832 wrote: > "R. David Murray" writes: > > > On Tue, 13 Oct 2015 14:59:56 +0300, Stefan Mihaila > > wrote: > >> Maybe it's just python2 habits, but I assume I'm not the only one > >> carelessly

Re: [Python-Dev] Rationale behind lazy map/filter

2015-10-13 Thread Graham Gower
On 14 October 2015 at 09:59, Steven D'Aprano wrote: > On Tue, Oct 13, 2015 at 11:26:09AM -0400, Random832 wrote: >> "R. David Murray" writes: >> >> > On Tue, 13 Oct 2015 14:59:56 +0300, Stefan Mihaila >> > wrote: >> >> Maybe

Re: [Python-Dev] PEP 0484 - the Numeric Tower

2015-10-13 Thread Raymond Hettinger
> On Oct 13, 2015, at 9:16 AM, Random832 wrote: > >> ## >> ## Decimal has all of the methods specified by the Real abc, but it should >> ## not be registered as a Real because decimals do not interoperate with >> ## binary floats (i.e. Decimal('3.14') +