Re: [Python-Dev] Best practices for Enum

2013-05-13 Thread Raymond Hettinger
On May 12, 2013, at 8:26 PM, Eli Bendersky eli...@gmail.com wrote: Thanks for the insights, Raymond. I don't think anyone is planning on rushing anything. We still have to get the enum module itself committed and a serious review process has just started for that, so it will take time.

[Python-Dev] Best practices for Enum

2013-05-13 Thread Stephen J. Turnbull
Raymond Hettinger writes: whether users will see any actual benefits (particularly for internal constants). I don't understand the parenthetical remark. It seems to me that changing internal constants should have the benefits that Ethan points to for understanding, debugging, and

Re: [Python-Dev] Best practices for Enum

2013-05-13 Thread Antoine Pitrou
Le Mon, 13 May 2013 00:06:52 -0700, Raymond Hettinger raymond.hettin...@gmail.com a écrit : On May 12, 2013, at 8:26 PM, Eli Bendersky eli...@gmail.com wrote: Thanks for the insights, Raymond. I don't think anyone is planning on rushing anything. We still have to get the enum module

Re: [Python-Dev] Best practices for Enum

2013-05-13 Thread Stefan Krah
Raymond Hettinger raymond.hettin...@gmail.com wrote: I would like to ask for a little restraint and for there to be individual cost/benefit evaluations for each case. +1 For external constants, some thought needs to be given to: * is the current API working just fine (i.e. decimal's

Re: [Python-Dev] Tightening up the specification for locals()

2013-05-13 Thread Maciej Fijalkowski
On Sun, May 12, 2013 at 2:01 PM, Antoine Pitrou solip...@pitrou.net wrote: On Fri, 03 May 2013 12:43:41 +1000 Steven D'Aprano st...@pearwood.info wrote: On 03/05/13 11:29, Nick Coghlan wrote: An exchange in one of the enum threads prompted me to write down something I've occasionally

[Python-Dev] weak refs in descriptors (http://bugs.python.org/issue17950)

2013-05-13 Thread Kristján Valur Jónsson
Hello python-dev. I'm working on a patch to remove reference cycles from heap-allocated classes: http://bugs.python.org/issue17950 Part of the patch involves making sure that descriptors in the class dictionary don't contain strong references to the class itself. This is item 2) in the defect

Re: [Python-Dev] Issue 11406: adding os.scandir(), a directory iterator returning stat-like info

2013-05-13 Thread Ben Hoyt
Okay, I've renamed my BetterWalk module to scandir and updated it as per our discussion: https://github.com/benhoyt/scandir/#readme It's not yet production-ready, and is basically still in API and performance testing stage. For instance, the underlying scandir_helper functions don't even return

Re: [Python-Dev] Issue 11406: adding os.scandir(), a directory iterator returning stat-like info

2013-05-13 Thread Stefan Drees
Hi Ben, Am 13.05.13 14:25, schrieb Ben Hoyt: ...It's not yet production-ready, and is basically still in API and performance testing stage. ... In any case, I really like the API (thanks mostly to Nick Coghlan), and performance is great, even with DirEntry being written in Python.

Re: [Python-Dev] Issue 11406: adding os.scandir(), a directory iterator returning stat-like info

2013-05-13 Thread Nick Coghlan
On Mon, May 13, 2013 at 10:25 PM, Ben Hoyt benh...@gmail.com wrote: Okay, I've renamed my BetterWalk module to scandir and updated it as per our discussion: https://github.com/benhoyt/scandir/#readme Nice! PERFORMANCE: On Windows I'm seeing that scandir.walk() on a large test tree (see

Re: [Python-Dev] weak refs in descriptors (http://bugs.python.org/issue17950)

2013-05-13 Thread Maciej Fijalkowski
On Mon, May 13, 2013 at 1:49 PM, Kristján Valur Jónsson krist...@ccpgames.com wrote: Hello python-dev. I‘m working on a patch to remove reference cycles from heap-allocated classes: http://bugs.python.org/issue17950 Part of the patch involves making sure that descriptors in the class

Re: [Python-Dev] weak refs in descriptors (http://bugs.python.org/issue17950)

2013-05-13 Thread Joao S. O. Bueno
On 13 May 2013 10:20, Maciej Fijalkowski fij...@gmail.com wrote: On Mon, May 13, 2013 at 1:49 PM, Kristján Valur Jónsson krist...@ccpgames.com wrote: Hello python-dev. I‘m working on a patch to remove reference cycles from heap-allocated classes: http://bugs.python.org/issue17950 Part of

Re: [Python-Dev] Tightening up the specification for locals()

2013-05-13 Thread Fábio Santos
Like it or not, people rely on this behavior. I don't think CPython (or PyPy) can actually afford to change it. If so, documenting it sounds like a better idea than leaving it undocumented only known to the inner shrine +1. I am relying on this.

Re: [Python-Dev] Best practices for Enum

2013-05-13 Thread Barry Warsaw
On May 12, 2013, at 04:49 PM, Raymond Hettinger wrote: After the long design effort for the enum module, I'm sure there will be a forthcoming effort to apply them pervasively throughout the standard library. We usually, explicitly, try not to do such wholesale adoptions in the stdlib when new

Re: [Python-Dev] Issue 11406: adding os.scandir(), a directory iterator returning stat-like info

2013-05-13 Thread Christian Heimes
Am 13.05.2013 02:21, schrieb Ben Hoyt: Are you suggesting just accessing .cached_lstat could call os.lstat()? That seems very bad to me. It's a property access -- it looks cheap, therefore people will expect it to be. From PEP 8 Avoid using properties for computationally expensive operations;

Re: [Python-Dev] Best practices for Enum

2013-05-13 Thread Ethan Furman
On 05/13/2013 12:06 AM, Raymond Hettinger wrote: Ethan's email suggests that against my advice he is in-fact going to go through the standard library, applying enums quite broadly. I think you are falling victim to Wizard's First Rule: people will believe what they want to be true, or are

Re: [Python-Dev] weak refs in descriptors (http://bugs.python.org/issue17950)

2013-05-13 Thread Terry Jan Reedy
On 5/13/2013 9:20 AM, Maciej Fijalkowski wrote: The strong reference there is a feature. Descriptors keep the class alive if somehow the class disappears and the descriptor itself does Is this feature stated or implied in the reference manual? 3.3.2.1. Implementing Descriptors 3.3.2.2.

Re: [Python-Dev] weak refs in descriptors (http://bugs.python.org/issue17950)

2013-05-13 Thread Antoine Pitrou
On Mon, 13 May 2013 13:21:17 -0400 Terry Jan Reedy tjre...@udel.edu wrote: On 5/13/2013 9:20 AM, Maciej Fijalkowski wrote: The strong reference there is a feature. Descriptors keep the class alive if somehow the class disappears and the descriptor itself does Is this feature stated or

Re: [Python-Dev] Issue 11406: adding os.scandir(), a directory iterator returning stat-like info

2013-05-13 Thread Ben Hoyt
I'd to see the numbers for NFS or CIFS - stat() can be brutally slow over a network connection (that's why we added a caching mechanism to importlib). How do I know what file system Windows networking is using? In any case, here's some numbers on Windows -- it's looking pretty good! This is

Re: [Python-Dev] Issue 11406: adding os.scandir(), a directory iterator returning stat-like info

2013-05-13 Thread Ben Hoyt
OK, you got me! I'm now convinced that a property is a bad idea. Thanks. :-) I still like to annotate that the function may return a cached value. Perhaps lstat() could require an argument? def lstat(self, cached): if not cached or self._lstat is None: self._lstat

Re: [Python-Dev] PEP 435 - ref impl disc 2

2013-05-13 Thread Ethan Furman
On 05/10/2013 10:15 PM, Glenn Linderman wrote: So it is quite possible to marry the two, as Ethan helped me figure out using an earlier NamedInt class: class NIE( IntET, Enum ): x = ('NIE.x', 1) y = ('NIE.y', 2) z = ('NIE.z', 4) and then expressions involving members of NIE

Re: [Python-Dev] PEP 435 - ref impl disc 2

2013-05-13 Thread Ethan Furman
On 05/13/2013 07:36 PM, Ethan Furman wrote: Here's your code, revamped. I did make a slight change in the meta -- I moved the name assignment above the __init__ call so it's available in __init__. --8 from ref435 import Enum from flags

Re: [Python-Dev] PEP 435 - ref impl disc 2

2013-05-13 Thread Glenn Linderman
On 5/13/2013 7:36 PM, Ethan Furman wrote: On 05/10/2013 10:15 PM, Glenn Linderman wrote: So it is quite possible to marry the two, as Ethan helped me figure out using an earlier NamedInt class: class NIE( IntET, Enum ): x = ('NIE.x', 1) y = ('NIE.y', 2) z = ('NIE.z', 4) and

[Python-Dev] PEP 435 doesn't help with bitfields [Was: Re: PEP 435 - ref impl disc 2]

2013-05-13 Thread Glenn Linderman
On 5/13/2013 7:36 PM, Ethan Furman wrote: 2) Is something like demo2 interesting to anyone but me? Of course, I think it would be great for reporting flag values using names rather than a number representing combined bit fields. No idea. ;) There's been some talk of Enum-ing constants in