Re: [Python-ideas] Callable Enum values

2017-04-16 Thread Steven D'Aprano
On Fri, Apr 14, 2017 at 06:06:29PM -0700, Stephan Hoyer wrote: > One way that I've found myself using enums recently is for dispatching (as > keys in a dictionary) between different interchangeable functions or > classes. My code looks something like this: > > from enum import Enum > > def foo(.

Re: [Python-ideas] Thread-safe generators

2017-04-16 Thread Victor Stinner
Thread safety is very complex and has an impact on performance. I dislike the idea of providing such property to generators which can have a complex next method. IMHO it's better to put a generator in wrapper which adds thread safety. What do you think? Victor Le 14 avr. 2017 18:48, "Serhiy Sto

Re: [Python-ideas] Callable Enum values

2017-04-16 Thread Ethan Furman
On 04/16/2017 01:24 AM, Steven D'Aprano wrote: On Fri, Apr 14, 2017 at 06:06:29PM -0700, Stephan Hoyer wrote: One way that I've found myself using enums recently is for dispatching (as keys in a dictionary) between different interchangeable functions or classes. [...] Given that wanting to

Re: [Python-ideas] Thread-safe generators

2017-04-16 Thread Guido van Rossum
I think the two shouldn't be mixed. On Apr 16, 2017 7:58 AM, "Victor Stinner" wrote: > Thread safety is very complex and has an impact on performance. I dislike > the idea of providing such property to generators which can have a complex > next method. > > IMHO it's better to put a generator in

Re: [Python-ideas] Thread-safe generators

2017-04-16 Thread Paul Moore
On 15 April 2017 at 10:45, Nick Coghlan wrote: > So I'd be opposed to trying to make generator objects natively thread > aware - as Stephen notes, the GIL is an implementation detail of > CPython, so it isn't OK to rely on it when defining changes to > language level semantics (in this case, wheth

Re: [Python-ideas] Discourage operator.__dunder__ functions

2017-04-16 Thread Steven D'Aprano
On Sat, Apr 15, 2017 at 12:09:39AM +1000, Nick Coghlan wrote: > On 14 April 2017 at 04:20, Steven D'Aprano wrote: > > Long ago, when the operator module was first introduced, there was a > > much stronger correspondence between the operator.__dunder__ functions > > and dunder methods. But I think

Re: [Python-ideas] Thread-safe generators

2017-04-16 Thread Nick Coghlan
On 17 April 2017 at 08:00, Paul Moore wrote: > On 15 April 2017 at 10:45, Nick Coghlan wrote: >> So I'd be opposed to trying to make generator objects natively thread >> aware - as Stephen notes, the GIL is an implementation detail of >> CPython, so it isn't OK to rely on it when defining changes