[Python-ideas] Re: asyncio: return from multiple coroutines

2020-06-22 Thread Kyle Stanley
I believe asyncio.wait() with "return_when=FIRST_COMPLETED" would perform the functionality you're looking for with the "asyncio.on_first_return()". For details on the functionality of asyncio.wait(), see https://docs.python.org/3/library/asyncio-task.html#asyncio.wait. > I understand that I can

[Python-ideas] asyncio: return from multiple coroutines

2020-06-22 Thread Pablo Alcain
Hey everyone. I have been looking into asyncio lately, and even though I have had my fair share of work, I still have some of it very shaky, so first of all forgive me if what I am saying here is already implemented and I totally missed it (so far, it looks *really* likely). Basically this is the

[Python-ideas] Re: Please consider adding numbers.Boolean

2020-06-22 Thread Christopher Barker
On Mon, Jun 22, 2020 at 10:19 AM Serhiy Storchaka wrote: > The abstract class for booleans is useless, because all objects can be > used in boolean context, and all boolean operations (and, or, not) work > with arbitrary objects. So Boolean would be identical to objects. > I'm highly ambivalent

[Python-ideas] Re: Please consider adding numbers.Boolean

2020-06-22 Thread Serhiy Storchaka
22.06.20 03:19, Neil Girdhar пише: I'm just curious if there was a reason why Boolean was omitted from the numeric tower in the numbers library?  It seems that builtins.bool and numpy.bool_ would both be elements of Boolean, and Boolean itself would be Integral? The abstract class for

[Python-ideas] Re: Proposal to introduce pattern matching syntax

2020-06-22 Thread Serhiy Storchaka
22.06.20 18:17, nate lust пише: Matching begins by calling a __match__ (class)method on the type, with the match target as a parameter. The match method must return an object that can be evaluated as a bool. If the return value is True, the code block in this match branch is executed, and

[Python-ideas] Re: Proposal to introduce pattern matching syntax

2020-06-22 Thread Joao S. O. Bueno
One should never underestimate the power of Guido's time machine. > ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/

[Python-ideas] Re: Proposal to introduce pattern matching syntax

2020-06-22 Thread Guido van Rossum
On Mon, Jun 22, 2020 at 8:20 AM nate lust wrote: > I have been working on an idea that would introduce pattern matching > syntax to python. I now have this syntax implemented in cpython, and feel > this is the right time to gather further input. The repository and branch > can be found at

[Python-ideas] Re: Proposal to introduce pattern matching syntax

2020-06-22 Thread Joao S. O. Bueno
On Mon, 22 Jun 2020 at 13:08, Michael Christensen wrote: > Concerning parameters in the as section: I think using `with` would make > it easier to understand. > > try match result: > as Dog: > print("Dog") > as Cat with lives: > print(f"Cat with {lives} lives") > as

[Python-ideas] Re: Proposal to introduce pattern matching syntax

2020-06-22 Thread Michael Christensen
Concerning parameters in the as section: I think using `with` would make it easier to understand. try match result: as Dog: print("Dog") as Cat with lives: print(f"Cat with {lives} lives") as tuple with (arg1, arg2): print(f"Tuple with args {arg1}, {arg2}")

[Python-ideas] Re: Please consider adding numbers.Boolean

2020-06-22 Thread Mark Dickinson
[Neil Girdhar] > It seems that builtins.bool and numpy.bool_ would both be elements of Boolean I'd be wary of trying to abstract over `bool` and `numpy.bool_`. There are some fundamental differences: - `bool` subclasses `int`; `numpy.bool_` is not a subclass of any integer type - moreover,

[Python-ideas] Re: Please consider adding numbers.Boolean

2020-06-22 Thread Eric V. Smith
On 6/21/2020 8:19 PM, Neil Girdhar wrote: I'm just curious if there was a reason why Boolean was omitted from the numeric tower in the numbers library?  It seems that builtins.bool and numpy.bool_ would both be elements of Boolean, and Boolean itself would be Integral? Is this being proposed

[Python-ideas] Re: Please consider adding numbers.Boolean

2020-06-22 Thread Jonathan Crall
I disagree that doing arithmetic on boolean variables doesn't make sense. Indicator variables which take a value of either zero are one are extremely common. Dirac or Kronecker delta functions are also examples of functions where it arithmetically makes sense to talk about values in the boolean

[Python-ideas] Proposal to introduce pattern matching syntax

2020-06-22 Thread nate lust
Hello, I have been working on an idea that would introduce pattern matching syntax to python. I now have this syntax implemented in cpython, and feel this is the right time to gather further input. The repository and branch can be found at https://github.com/natelust/cpython/tree/match_syntax.

[Python-ideas] Re: Permanent code objects (less memory, quicker load, less Unix Copy On Write)

2020-06-22 Thread Jonathan Fine
Hi SUMMARY: We're starting to discuss implementation. I'm going to focus on what can be done, with only a few changes to the interpreter. First consider this: >>> from sys import getrefcount as grc >>> def fn(obj): return grc(obj) >>> grc(fn.__code__), grc(fn.__code__.co_code)

[Python-ideas] Re: Permanent code objects (less memory, quicker load, less Unix Copy On Write)

2020-06-22 Thread Guido van Rossum
I like where this is going. It would be nice if certain constants could also be loaded from RO memory. On Mon, Jun 22, 2020 at 00:16 Inada Naoki wrote: > On Mon, Jun 22, 2020 at 12:00 AM Guido van Rossum > wrote: > > > > > > I believe this was what Greg Stein's idea here was about. (As well as

[Python-ideas] Re: Permanent code objects (less memory, quicker load, less Unix Copy On Write)

2020-06-22 Thread M.-A. Lemburg
If you want to proceed in this direction, it would be better to do some more research into current CPU architectures and then build a VM optimized byte code storage object, which is well aligned, fits into today's caches and improves locality. freeze.py could then write out this format as well,

[Python-ideas] Re: Permanent code objects (less memory, quicker load, less Unix Copy On Write)

2020-06-22 Thread Inada Naoki
On Mon, Jun 22, 2020 at 8:27 PM Barry Scott wrote: > > * New code and pyc format > * pyc has "rodata" segment >* It can be copied into single memory block, or can be mmapped. > * co_code should be aligned at least 2 bytes. > > > Would higher alignment help? malloc is using 8 or 16 byte

[Python-ideas] Re: Permanent code objects (less memory, quicker load, less Unix Copy On Write)

2020-06-22 Thread Barry Scott
Let's try again... > On 22 Jun 2020, at 08:15, Inada Naoki wrote: > > On Mon, Jun 22, 2020 at 12:00 AM Guido van Rossum wrote: >> >> >> I believe this was what Greg Stein's idea here was about. (As well as >> Jonathan Fine's in this thread?) But the current use of code objects makes >>

[Python-ideas] Re: Permanent code objects (less memory, quicker load, less Unix Copy On Write)

2020-06-22 Thread Barry Scott
> On 22 Jun 2020, at 08:15, Inada Naoki wrote: > > On Mon, Jun 22, 2020 at 12:00 AM Guido van Rossum wrote: >> >> >> I believe this was what Greg Stein's idea here was about. (As well as >> Jonathan Fine's in this thread?) But the current use of code objects makes >> this hard. Perhaps

[Python-ideas] Re: Please consider adding numbers.Boolean

2020-06-22 Thread Greg Ewing
On 22/06/20 12:19 pm, Neil Girdhar wrote: I'm just curious if there was a reason why Boolean was omitted from the numeric tower in the numbers library? Python's bool type is a subclass of int for historical reasons, not because it's conceptually a numeric type. Doing arithmetic on it doesn't

[Python-ideas] Re: Permanent code objects (less memory, quicker load, less Unix Copy On Write)

2020-06-22 Thread Chris Angelico
On Mon, Jun 22, 2020 at 5:19 PM Inada Naoki wrote: > I think lightweight bytes-like object is better. My rough idea is: > > * New code and pyc format > * pyc has "rodata" segment > * It can be copied into single memory block, or can be mmapped. > * co_code should be aligned at least

[Python-ideas] Re: Permanent code objects (less memory, quicker load, less Unix Copy On Write)

2020-06-22 Thread Inada Naoki
On Mon, Jun 22, 2020 at 12:00 AM Guido van Rossum wrote: > > > I believe this was what Greg Stein's idea here was about. (As well as > Jonathan Fine's in this thread?) But the current use of code objects makes > this hard. Perhaps the code objects could have a memoryview object to hold > the