[Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread Stefan Krah
Yury Selivanov wrote: > This is a new PEP to implement Execution Contexts in Python. The idea is of course great! A couple of issues for decimal: > Moreover, passing the context explicitly does not work at all for > libraries like ``decimal`` or ``numpy``, which use operator overloading.

Re: [Python-ideas] Towards harmony with JavaScript?

2017-08-12 Thread Alberto Berti
> "Chris" == Chris Angelico writes: Chris> On Sat, Aug 12, 2017 at 6:31 AM, Alberto Berti wrote: >> As of now, I do nothing. As I said, the goal of the tool is not to >> shield you from JS, for this reason it's not meant for beginners

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread Nathaniel Smith
Hi Yury, This is really cool. Some notes on a first read: 1. Excellent work on optimizing dict, that seems valuable independent of the rest of the details here. 2. The text doesn't mention async generators at all. I assume they also have an agi_isolated_execution_context flag that can be set,

Re: [Python-ideas] Towards harmony with JavaScript?

2017-08-12 Thread Alberto Berti
> "Carl" == Carl Smith writes: Carl> Using lambdas doesn't solve the problem. I just kept the example short, but Carl> had I used more than one expression in each function, you'd be back to Carl> square one. You took advantage of the brevity of the example,

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread Nick Coghlan
On 12 August 2017 at 15:45, Yury Selivanov wrote: > Thanks Eric! > > PEP 408 -- Standard library __preview__ package? Typo in the PEP number: PEP 406, which was an ultimately failed attempt to get away from the reliance on process globals to manage the import system by

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread Nathaniel Smith
I had an idea for an alternative API that exposes the same functionality/semantics as the current draft, but that might have some advantages. It would look like: # a "context item" is an object that holds a context-sensitive value # each call to create_context_item creates a new one ci =

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread Yury Selivanov
Yes, I considered this idea myself, but ultimately rejected it because: 1. Current solution makes it easy to introspect things. Get the current EC and print it out. Although the context item idea could be extended to `sys.create_context_item('description')` to allow that. 2. What if we want to

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread Nick Coghlan
On 13 August 2017 at 03:53, Yury Selivanov wrote: > On Sat, Aug 12, 2017 at 1:09 PM, Nick Coghlan wrote: >> Now that you raise this point, I think it means that generators need >> to retain their current context inheritance behaviour, simply for >>

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread Nathaniel Smith
On Sat, Aug 12, 2017 at 6:27 PM, Yury Selivanov wrote: > Yes, I considered this idea myself, but ultimately rejected it because: > > 1. Current solution makes it easy to introspect things. Get the > current EC and print it out. Although the context item idea could be >

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread Kevin Conway
As far as providing a thread-local like surrogate for coroutine based systems in Python, we had to solve this for Twisted with https://bitbucket.org/hipchat/txlocal. Because of the way the Twisted threadpooling works we also had to make a context system that was both coroutine and thread safe at

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread Nick Coghlan
On 12 August 2017 at 08:37, Yury Selivanov wrote: > Hi, > > This is a new PEP to implement Execution Contexts in Python. > > The PEP is in-flight to python.org, and in the meanwhile can > be read on GitHub: > > https://github.com/python/peps/blob/master/pep-0550.rst > >

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread rym...@gmail.com
So, I'm hardly an expert when it comes to things like this, but there are two things about this that don't seem right to me. (Also, I'd love to respond inline, but that's kind of difficult from a mobile phone.) The first is how set/get_execution_context_item take strings. Inevitably, people are

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread Yury Selivanov
On Sat, Aug 12, 2017 at 2:28 PM, rym...@gmail.com wrote: > So, I'm hardly an expert when it comes to things like this, but there are > two things about this that don't seem right to me. (Also, I'd love to > respond inline, but that's kind of difficult from a mobile phone.) > >

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread Yury Selivanov
Sure, I'll do. Yury ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Towards harmony with JavaScript?

2017-08-12 Thread Carl Smith
Alberto, CoffeeScript is a popular language that is widely considered to represent JavaScript's best bits, and it only has anonymous functions, so there's a large part of the JS community that disagrees with you there. Browsers actually do identify anonymous functions, based on the

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread Guido van Rossum
Thanks for the explanation. Can you make sure this is explained in the PEP? On Aug 11, 2017 10:43 PM, "Yury Selivanov" wrote: > > On Fri, Aug 11, 2017 at 10:17 PM, Guido van Rossum > wrote: > > > I may have missed this (I've just skimmed the doc), but

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread Nick Coghlan
On 12 August 2017 at 17:54, Nathaniel Smith wrote: > ...and now that I've written that down, I sort of feel like that might > be what you want for all the other sorts of context object too? Like, > here's a convoluted example: > > def gen(): > a = decimal.Decimal("1.111") >

Re: [Python-ideas] Towards harmony with JavaScript?

2017-08-12 Thread Nick Coghlan
On 12 August 2017 at 06:10, Chris Barker wrote: > >> > Taking this off the list as it's no longer on topic. > > > not totally -- I'm going to add my thoughts: > > 1) If you want a smoother transition between server-side Python and > in-browser code, maybe you're better off

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread Yury Selivanov
Nick, Nathaniel, I'll be replying in full to your emails when I have time to do some experiments. Now I just want to address one point that I think is important: On Sat, Aug 12, 2017 at 1:09 PM, Nick Coghlan wrote: > On 12 August 2017 at 17:54, Nathaniel Smith

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread Yury Selivanov
[replying to list] On Sat, Aug 12, 2017 at 10:56 PM, Nick Coghlan wrote: > On 13 August 2017 at 11:27, Yury Selivanov wrote: >> Yes, I considered this idea myself, but ultimately rejected it because: >> >> 1. Current solution makes it easy to

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread Nick Coghlan
On 13 August 2017 at 12:15, Nathaniel Smith wrote: > On Sat, Aug 12, 2017 at 6:27 PM, Yury Selivanov > wrote: >> Yes, I considered this idea myself, but ultimately rejected it because: >> >> 1. Current solution makes it easy to introspect things. Get the

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread Nathaniel Smith
On Sat, Aug 12, 2017 at 9:05 PM, Nick Coghlan wrote: > On 13 August 2017 at 12:15, Nathaniel Smith wrote: >> On Sat, Aug 12, 2017 at 6:27 PM, Yury Selivanov >> wrote: >>> Yes, I considered this idea myself, but ultimately rejected it

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread Nick Coghlan
On 13 August 2017 at 11:27, Yury Selivanov wrote: > Yes, I considered this idea myself, but ultimately rejected it because: > > 1. Current solution makes it easy to introspect things. Get the > current EC and print it out. Although the context item idea could be >

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread Yury Selivanov
Nathaniel, Nick, I'll reply only to point 9 in this email to split this threads into manageable sub-threads. I'll cover other points in later emails. On Sat, Aug 12, 2017 at 3:54 AM, Nathaniel Smith wrote: > 9. OK, my big question, about semantics. FWIW I took me a good hour

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-12 Thread Pau Freixes
Good work Yuri, going for all in one will help to not increase the diferences btw async and the sync world in Python. I do really like the idea of the immutable dicts, it makes easy inherit the context btw tasks/threads/whatever without put in risk the consistency if there is further key