Re: [Python-Dev] Enum conversions in the stdlib

2017-03-03 Thread Guyzmo via Python-Dev
On Thu, Mar 02, 2017 at 04:13:17PM -0800, Ethan Furman wrote:
> The resulting enumeration is neither in alpha nor value order.  While this
> has no bearing on programmatic usage I would like these Enums to be ordered,
> preferably by value.
>
> Would anyone prefer lexicographical ordering, and if so, why?

I just tried on my system with python 3.6:

```
>>> pprint(list(signal.Signals))
[,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
 ]
```

so I'm not sure what the issue is, but #worksforme.

-- 
zmo
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Possible bug in class-init, lookin for mentors

2017-04-21 Thread Guyzmo via Python-Dev
On Fri, Apr 21, 2017 at 11:47:24AM +0200, Justus Schwabedal wrote:
> At least I think it's a bug.  Maybe it's a feature..

it's indeed a feature.

> I possibly found a bug in class __init__ and would like to fix it

technically, it's a method. More precisely, it's the constructor method.

> So I'm looking for a mentor to help me.
> 
> class Foo:
> def __init__(self, bar=[]):
> self.list = bar
> 
> spam_1 = Foo()
> spam_2 = Foo()
> 
> spam_1.list.append(42)
> print(spam_2.list)`

the argument `bar` of your method is instanciated at the time you're
declaring the method. It's happening once for the the lifetime of the
execution of your code.

By allocating the `bar` reference into the `self.list` member, you're
assigning the same *instance* of that list into the `self.list` member.

So everytime you create a new Foo instance, you're actually assigning
the same `[]` instance into `self.list` which is why, when you mutate
the list, it's happening in all the instances of Foo as well.

I hope it makes sense to you !

-- 
Guyzmo
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] "Micro-optimisations can speed up CPython"

2017-05-29 Thread Guyzmo via Python-Dev
On Mon, May 29, 2017 at 05:15:43PM +0300, Serhiy Storchaka wrote:
> Interesting articles, thank you. I wonder why the author doesn't propose his
> patches for CPython. Does he fear that CPython can become faster than Lua?
> ;-)

the author's answer: https://twitter.com/corsix/status/869200284261789696

😉

Cheers,

-- 
zmo
___
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com