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

2015-10-14 Thread Chris Barker - NOAA Federal
> Yes, but what I expect the type annotations to be used for, especially > in the SciPy world, is to make things easier for Numba to generate fast > code. Well, probably not. There are two reasons to have type declarations: performance and type safety. But the current type annotations are design

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

2015-10-14 Thread Laura Creighton
In a message of Wed, 14 Oct 2015 23:49:33 +0100, Oscar Benjamin writes: >I'm sure the bokeh developers will be aware of the different ways that >their library is used (at this level). If the input spec is "sequence of >coercible to float" then I agree that they should use type annotations to >match

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

2015-10-14 Thread Oscar Benjamin
On 14 Oct 2015 23:06, "Laura Creighton" wrote: > > In a message of Wed, 14 Oct 2015 21:21:30 -, Oscar Benjamin writes: > >Generally if it's possible to interchange floats and decimals in your code > >then there's probably no need for decimals in the first place. > > Yes, but, at least around h

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

2015-10-14 Thread Laura Creighton
I forgot something. In a message of Wed, 14 Oct 2015 21:21:30 -, Oscar Benjamin writes: >The point of static type checking is to detect precisely these kinds of >errors. Yes, but what I expect the type annotations to be used for, especially in the SciPy world, is to make things easier for N

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

2015-10-14 Thread Chris Barker
On Wed, Oct 14, 2015 at 3:04 PM, Laura Creighton wrote: > That code writers in the scientific python world mostly > never think of Decimal users, doesn't mean they don't end up writing > perfectly wonderful tools and libraries we use. :) thankfully :) > sure -- but those are almost guaranteed

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

2015-10-14 Thread Laura Creighton
In a message of Wed, 14 Oct 2015 21:21:30 -, Oscar Benjamin writes: >Generally if it's possible to interchange floats and decimals in your code >then there's probably no need for decimals in the first place. Yes, but, at least around here the common case is that you already _have_ a pile of

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

2015-10-14 Thread Oscar Benjamin
On Wed, 14 Oct 2015 21:57 Laura Creighton wrote: In a message of Wed, 14 Oct 2015 08:38:43 -0700, Guido van Rossum writes: >Perhaps you could solve this with type variables. Here's a little >demonstration program: >``` >from decimal import Decimal >from typing import TypeVar >F = TypeVar('F', flo

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

2015-10-14 Thread Laura Creighton
In a message of Wed, 14 Oct 2015 08:38:43 -0700, Guido van Rossum writes: >Perhaps you could solve this with type variables. Here's a little >demonstration program: >``` >from decimal import Decimal >from typing import TypeVar >F = TypeVar('F', float, Decimal) >def add(a: F, b: F) -> F: >return

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

2015-10-14 Thread Chris Barker - NOAA Federal
>> Well, that's what you get in exchange for "type safety". > > AIUI, the point of type annotations is that some use cases benefit *a > lot* from machine-parsable type information, not that type annotation > is a universally good idea in itself. It's not type *safety* that's > the aim here. It's

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

2015-10-14 Thread Guido van Rossum
Perhaps you could solve this with type variables. Here's a little demonstration program: ``` from decimal import Decimal from typing import TypeVar F = TypeVar('F', float, Decimal) def add(a: F, b: F) -> F: return a+b print(add(4.2, 3.14)) print(add(Decimal('4.2'), Decimal('3.14'))) print(add(D

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

2015-10-14 Thread Chris Barker - NOAA Federal
And these days > anybody who is using Decimal for Money (which ought to be everybody, I'm not so sure about that -- using base-10 is nice, but it doesn't automatically buy you the appropriate rounding rules, etc that you need to "proper" accounting. And, as MA pointed out, in much "finance" work,

Re: [Python-Dev] under what circumstances can python still exhibit "high water mark" memory usage?

2015-10-14 Thread Chris Withers
On 14/10/2015 16:13, Victor Stinner wrote: Hi, You may also try tracemalloc to get stats of the Python memory usage ;-) The Python memory allocator was optimized in Python 3.3: it now uses mmap() when available (on UNIX), it helps to reduce the fragmentation of the heap memory. Since Python 3.4

Re: [Python-Dev] under what circumstances can python still exhibit "high water mark" memory usage?

2015-10-14 Thread Victor Stinner
Hi, You may also try tracemalloc to get stats of the Python memory usage ;-) The Python memory allocator was optimized in Python 3.3: it now uses mmap() when available (on UNIX), it helps to reduce the fragmentation of the heap memory. Since Python 3.4, VirtualAlloc() is used for the same purpose

Re: [Python-Dev] under what circumstances can python still exhibit "high water mark" memory usage?

2015-10-14 Thread Chris Withers
On 14/10/2015 16:04, Stefan Ring wrote: On Wed, Oct 14, 2015 at 3:11 PM, Chris Withers wrote: I'm having trouble with some python processes that are using 3GB+ of memory but when I inspect them with either heapy or meliae, injected via pyrasite, those tools only report total memory usage to be

Re: [Python-Dev] under what circumstances can python still exhibit "high water mark" memory usage?

2015-10-14 Thread Stefan Ring
On Wed, Oct 14, 2015 at 3:11 PM, Chris Withers wrote: > I'm having trouble with some python processes that are using 3GB+ of memory > but when I inspect them with either heapy or meliae, injected via pyrasite, > those tools only report total memory usage to be 119Mb. > > This feels like the old "p

[Python-Dev] under what circumstances can python still exhibit "high water mark" memory usage?

2015-10-14 Thread Chris Withers
Hi All, I'm having trouble with some python processes that are using 3GB+ of memory but when I inspect them with either heapy or meliae, injected via pyrasite, those tools only report total memory usage to be 119Mb. This feels like the old "python high water mark" problem, but I thought that

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

2015-10-14 Thread Laura Creighton
In a message of Wed, 14 Oct 2015 11:44:40 +0200, "M.-A. Lemburg" writes: >I can only underline this. Conversion to decimals or fractions should >not be implicit. People needing these types will know when they need >them and apply the required explicit conversions to fit their use case. > >E.g. in

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

2015-10-14 Thread M.-A. Lemburg
On 14.10.2015 01:37, Raymond Hettinger wrote: > >> 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 flo