[Python-ideas] Re: await by default

2020-06-13 Thread Greg Ewing
On 13/06/20 3:02 pm, Steven D'Aprano wrote: Coroutines are lighter weight than threads because they don't need all the machinary to pre-emptively run threads in parallel; threads are lighter weight than processes because they don't need to be in separate memory spaces enforced by the OS. Well,

[Python-ideas] Re: await by default

2020-06-13 Thread J. Pic
I'm not sure I should rewrite my asyncio code to threading, I'll just keep going asyncio, maybe one day it'll be possible to get the best of both worlds ... On #python they generally tell me that the extra syntax is worth it because of the internal details, that rewriting to threads does not seem

[Python-ideas] For quicker execution, don't refcount objects that can't be deleted

2020-06-13 Thread Jonathan Fine
Hi Here's something that might make code run quicker. The basic idea is to not refcount some objects that are sure never to be deleted. On a multicore machine, this might significantly reduce the number of cache invalidations (and perhaps misses). I lack many of the skills needed to investigate th

[Python-ideas] Re: await by default

2020-06-13 Thread Chris Angelico
On Sat, Jun 13, 2020 at 8:14 PM J. Pic wrote: > > I'm not sure I should rewrite my asyncio code to threading, I'll just keep > going asyncio, maybe one day it'll be possible to get the best of both worlds > ... > > On #python they generally tell me that the extra syntax is worth it because > of

[Python-ideas] Operator ">" for functions

2020-06-13 Thread artem6191
This operator will allow to send arguments to function only by certain values. Example: def some_function(a > (1, 2,3), b): # Some code some_function(1, 2) some_function(4, 2) # Error "Value '4' is not allowed for argument 'a'" ___ Python-ideas maili

[Python-ideas] Re: Operator ">" for functions

2020-06-13 Thread Alex Hall
Wouldn't it make more sense to write `def some_function(a in (1, 2,3), b):`, meaning `a in (1, 2,3)` must be true? Similarly you could have `def some_function(a > 0):` to mean `a > 0` must be true. On Sat, Jun 13, 2020 at 2:55 PM artem6191 wrote: > This operator will allow to send arguments to f

[Python-ideas] Re: Bringing the print statement back

2020-06-13 Thread João Bernardo
> > >>> print (1, 2, 3) > 1 2 3 > The only real advantage of print being a keyword (exec too, which had tons of benefits such adding stuff to local scope) was the fact of it actually being a keyword and not a gimmick to call functions without parentheses. So this is the worst of 2 worlds. Not a k

[Python-ideas] Postpone Python 4 for another 5 years

2020-06-13 Thread João Bernardo
Now that double digits reached Python 3 and for the sake of maintaining compatibility for longer since Python 2.7 recently passed away and people is finally migrating after 12 years, I propose 5 new Python 3 versions: So we can have Python 3.10, 3.11, 3.12, 3.13 and finally 3.14 a.k.a Pi-thon Re

[Python-ideas] Re: Postpone Python 4 for another 5 years

2020-06-13 Thread Jonathan Fine
Hi João You wrote: > So we can have Python 3.10, 3.11, 3.12, 3.13 and finally 3.14 a.k.a Pi-thon > What a lovely idea. There's good precedent for this: $ tex This is TeX, Version 3.14159265 $ mf This is METAFONT, Version 2.7182818 (TeX Live 2019) (preloaded base=mf) Aside: Each

[Python-ideas] Re: Postpone Python 4 for another 5 years

2020-06-13 Thread Steele Farnsworth
Is Python 4 being planned at the moment? What backwards incompatible changes would it introduce? Steele On Sat, Jun 13, 2020, 9:22 AM João Bernardo wrote: > Now that double digits reached Python 3 and for the sake of > maintaining compatibility for longer since Python 2.7 recently passed away >

[Python-ideas] Re: await outside async function

2020-06-13 Thread Soni L.
On 2020-06-13 2:32 a.m., Kyle Stanley wrote: > An await outside async def, would map to awaitable.run(). > A call to baz() would thus create a coroutine foo(), and then run() it. -1. The `await` expression already has a well-defined purpose of suspending the coroutine it's used within until

[Python-ideas] Re: Postpone Python 4 for another 5 years

2020-06-13 Thread Chris Angelico
On Sun, Jun 14, 2020 at 12:06 AM Steele Farnsworth wrote: > > Is Python 4 being planned at the moment? What backwards incompatible changes > would it introduce? > It isn't, so "postpone Python 4" really just means "keep doing what's already happening". At present, it seems fairly likely that the

[Python-ideas] Re: Bringing the print statement back

2020-06-13 Thread Antoine Pitrou
Can I just write "boo, hiss"? In any case, even if those may be made unambiguous for the current parser (I have no idea if that's true), they're visually ambiguous for a human reader. With parentheses, it's immediate what are function calls. Without, it's far less obvious whether such calls ar

[Python-ideas] Re: await by default

2020-06-13 Thread J. Pic
> Your project is fundamentally about instantiating processes? Yes, that and spawning other subprocesses depending on the outcome of the previous one, sometimes concurrently per-host but mostly sequentially, and clearly most of the time will be spent waiting for suprocesses because all my commands

[Python-ideas] Re: Operator ">" for functions

2020-06-13 Thread Paul Moore
On Sat, 13 Jun 2020 at 13:54, artem6191 wrote: > > This operator will allow to send arguments to function only by certain values. > Example: > > def some_function(a > (1, 2,3), b): ># Some code > some_function(1, 2) > some_function(4, 2) # Error "Value '4' is not allowed for argument 'a'" def

[Python-ideas] Re: await outside async function could map to asyncio.run ?

2020-06-13 Thread Greg Ewing
On 13/06/20 8:47 am, J. Pic wrote: Why not make using await do asyncio.run "behind the scenes" when called outside async function ? That would directly tie the await syntax to the asyncio module. This would not be a good idea. Currently there is nothing special about asyncio -- it's just one of

[Python-ideas] Re: await by default

2020-06-13 Thread Greg Ewing
Allowing the 'await' keyword to be omitted would also present some semantic and implementation difficulties. The mechanism behind 'await' is essentially the same as 'yield from', so you're more or less asking for 'yield from' to be automagically applied to the result of an expression. But this wo

[Python-ideas] Re: await by default

2020-06-13 Thread Chris Angelico
On Sun, Jun 14, 2020 at 9:54 AM Greg Ewing wrote: > But this would require reading the programmer's mind, because it's > quite legitimate to create an iterator and keep it around to be > yielded from later. Likewise, it's legitimate to create an awaitable > object and then await it later. > > (Per

[Python-ideas] Re: await by default

2020-06-13 Thread Greg Ewing
On 14/06/20 12:05 pm, Chris Angelico wrote: On Sun, Jun 14, 2020 at 9:54 AM Greg Ewing wrote: Likewise, it's legitimate to create an awaitable object and then await it later. (Personally I think it *shouldn't* be legitimate to do that in the case of await, but Guido thinks otherwise, so it is

[Python-ideas] Re: await by default

2020-06-13 Thread Chris Angelico
On Sun, Jun 14, 2020 at 11:29 AM Greg Ewing wrote: > > On 14/06/20 12:05 pm, Chris Angelico wrote: > > On Sun, Jun 14, 2020 at 9:54 AM Greg Ewing > > wrote: > >> Likewise, it's legitimate to create an awaitable > >> object and then await it later. > >> > >> (Personally I think it *shouldn't* be

[Python-ideas] Re: await by default

2020-06-13 Thread Kyle Stanley
> If you're fine with invisible context switches, you're probably better off with threads, because they're not vulnerable to unexpectedly blocking actions (a common culprit being name lookups before network transactions - you can connect sockets asynchronously, but gethostbyname will block the curr

[Python-ideas] Re: await by default

2020-06-13 Thread Greg Ewing
On 14/06/20 1:42 pm, Chris Angelico wrote: Hmm, I think I see what you mean. So awaiting it would be "spam(123)" No, it would still be "await spam(123)". It's just that you wouldn't be able to separate the await from the call, so this wouldn't be allowed: a = spam(123) await a Incidenta

[Python-ideas] Re: await by default

2020-06-13 Thread Chris Angelico
On Sun, Jun 14, 2020 at 2:16 PM Kyle Stanley wrote: > > > If > you're fine with invisible context switches, you're probably better > off with threads, because they're not vulnerable to unexpectedly > blocking actions (a common culprit being name lookups before network > transactions - you can conn

[Python-ideas] Re: await by default

2020-06-13 Thread Kyle Stanley
> IOW the solution to the problem is to use threads. You can see here why I said what I did: threads specifically avoid this problem and the only way for asyncio to avoid it is to use threads. In the case of the above example, I'd say it's more so "use coroutines by default and threads as needed"

[Python-ideas] Re: await by default

2020-06-13 Thread Kyle Stanley
> for any IO-bound call with a variable time where async isn't an option (either because it's not available, standardized, widespread, etc.), I'd advise using loop.run_in_executor()/to_thread() preemptively. Clarification: this pretty much applies to any non-async IO-bound call that can block the