On Sun, Aug 9, 2020, 12:07 AM Steven D'Aprano
> > [*] For languages with bounded data types, this is more compelling. If
> I think a variable will *definitely* fit in a uint8, having the static tool
> tell me it might not is powerful.
>
> uint8 = int[0:256]
>
> So if it's useful to know that
On Sat, Aug 08, 2020 at 08:13:53PM -0400, David Mertz wrote:
> Yes, this is absolutely doable! I guess my argument in several posts is
> that this simple level of analysis of "possible bounds violation" is rarely
> useful (at least in a Python context[*]). Vastly more complicated formal
> proofs
On 9/08/20 10:43 am, Guido van Rossum wrote:
But integer ranges? I guess they would be useful to catch array indexing
mistakes,
I'm not sure they would. For an index error to be caught at compile
time, the thing being indexed has to have a size known to the
compiler. This was always the case
On Sat, Aug 8, 2020, 7:40 PM Steven D'Aprano
> Any checker capable of doing bounds checks would know that the range of
> possible ints is unbounded in both directions, and therefore an int does
> not fit into the range [1:10**9]. Hence that will be a static bounds
> check failure:
Just so you
On Sat, Aug 08, 2020 at 01:28:59AM -0400, David Mertz wrote:
> On Sat, Aug 8, 2020, 1:12 AM Steven D'Aprano
>
> > Static languages often check what
> > bounds they can at compile time, and optionally insert bound checking
> > runtime code for ambiguous places.
>
>
> Yep. That's an assert, or
On 2020-08-08 at 18:53:36 -0400,
David Mertz wrote:
> ... my discovery was that "LLVM figures out Gauss' simplification and
> does it in constant time no matter the N. After that I looked at the
> LLVM bytecode to see, "Yup, it does." The optimizer is pretty smart
> about variations in writing
On Sat, Aug 8, 2020 at 5:49 PM Michael Smith wrote:
> This kind of thing is so powerful, and I would love to see tooling capable
> of it in the python ecosystem. I believe folks who say it's very hard to
> implement correctly, but I don't know that that's a good reason not to make
> the proposed
This thread seems light on real use cases. I know there are people eager to
have integer generics, since they are essential for typing numpy, pandas,
tensorflow and friends. And so there are good proposals floating around for
this on typing-sig; I expect implementations within a year.
But integer
On Sat, Aug 8, 2020 at 5:51 PM Michael Smith wrote:
> This kind of thing is so powerful, and I would love to see tooling capable
> of it in the python ecosystem. I believe folks who say it's very hard to
> implement correctly, but I don't know that that's a good reason not to make
> the proposed
On Sat, Aug 8, 2020 at 16:41 Dominik Vilsmeier
wrote:
> On 08.08.20 05:48, David Mertz wrote:
>
> On Fri, Aug 7, 2020, 6:03 PM Paul Moore wrote:
>
>> > x: int[0:] # any ints greater than or equal to zero would match,
>> others would fail
>> > x: int[:101] # any ints less than 101 match
>> >
On 08.08.20 05:48, David Mertz wrote:
On Fri, Aug 7, 2020, 6:03 PM Paul Moore mailto:p.f.mo...@gmail.com>> wrote:
> x: int[0:] # any ints greater than or equal to zero would
match, others would fail
> x: int[:101] # any ints less than 101 match
> x: int[0:101:2] # even less
Oops, obviously I meant:
def plusone(i: int[1:1_000_000_000]):
return i+1
random.seed(42)
for n in range(1_000_000):
plusone(random.randint(1, 1_000_000_001))
Or a zillion other things. I can construct orbitals of Mandelbrot set that
may or may not be bounded. Or bounds that depend on
On Fri, Aug 07, 2020 at 05:44:31PM -0400, Ricky Teachey wrote:
> Would it make good semantic sense- and be useful- to specify valid
> numerical ranges using slices and type-hint syntax? My suggestion would be
> to, at minimum, provide this functionality for int and float.
We know that
On Sat, Aug 8, 2020, 1:12 AM Steven D'Aprano
> Static languages often check what
> bounds they can at compile time, and optionally insert bound checking
> runtime code for ambiguous places.
Yep. That's an assert, or it's moral equivalent.
Here's a deterministic program using the hypothetical
On Fri, Aug 07, 2020 at 11:48:40PM -0400, David Mertz wrote:
> On Fri, Aug 7, 2020, 6:03 PM Paul Moore wrote:
>
> > > x: int[0:] # any ints greater than or equal to zero would match, others
> > would fail
> > > x: int[:101] # any ints less than 101 match
> > > x: int[0:101:2] # even less than
On Sat, Aug 8, 2020, 12:18 AM Ricky Teachey
> Yes, it's hard in the sense that it would require solving the halting
>> problem.
>>
>
> That doesn't sound so hard. ;)
>
> Thanks for educating me. Could it at least be useful for:
>
> 1. Providing semantic meaning to code (but this is probably not
On Fri, Aug 7, 2020 at 11:48 PM David Mertz wrote:
> On Fri, Aug 7, 2020, 6:03 PM Paul Moore wrote:
>
>> > x: int[0:] # any ints greater than or equal to zero would match,
>> others would fail
>> > x: int[:101] # any ints less than 101 match
>> > x: int[0:101:2] # even less than 101
>>
>> I
On Fri, Aug 7, 2020, 6:03 PM Paul Moore wrote:
> > x: int[0:] # any ints greater than or equal to zero would match, others
> would fail
> > x: int[:101] # any ints less than 101 match
> > x: int[0:101:2] # even less than 101
>
> I suspect the biggest issue with this is that it's likely to be
On Fri, Aug 7, 2020 at 6:01 PM Paul Moore wrote:
> On Fri, 7 Aug 2020 at 22:46, Ricky Teachey wrote:
> >
> > This was inspired by a tweet today from Brandon Rhodes. I looked for
> something like it on the mypy issues page and didn't find anything.
> >
> > Would it make good semantic sense- and
On Fri, 7 Aug 2020 at 22:46, Ricky Teachey wrote:
>
> This was inspired by a tweet today from Brandon Rhodes. I looked for
> something like it on the mypy issues page and didn't find anything.
>
> Would it make good semantic sense- and be useful- to specify valid numerical
> ranges using slices
20 matches
Mail list logo