Re: [Python-Dev] Remaining decisions on PEP 471 -- os.scandir()

2014-07-15 Thread Cameron Simpson
I was going to stay out of this one... On 14Jul2014 10:25, Victor Stinner wrote: 2014-07-14 4:17 GMT+02:00 Nick Coghlan : Or the ever popular symlink to "." (or a directory higher in the tree). "." and ".." are explicitly ignored by os.listdir() an os.scandir(). I think os.walk() is a good

Re: [Python-Dev] Another case for frozendict

2014-07-15 Thread MRAB
On 2014-07-16 00:48, Russell E. Owen wrote: In article , Chris Angelico wrote: On Mon, Jul 14, 2014 at 12:04 AM, Jason R. Coombs wrote: > I can achieve what I need by constructing a set on the ‘items’ of the dict. > set(tuple(doc.items()) for doc in res) > > {(('n', 1), ('err', No

Re: [Python-Dev] Another case for frozendict

2014-07-15 Thread Russell E. Owen
In article , Chris Angelico wrote: > On Mon, Jul 14, 2014 at 12:04 AM, Jason R. Coombs wrote: > > I can achieve what I need by constructing a set on the ‘items’ of the > > dict. > > > set(tuple(doc.items()) for doc in res) > > > > {(('n', 1), ('err', None), ('ok', 1.0))} > > This is

Re: [Python-Dev] Remaining decisions on PEP 471 -- os.scandir()

2014-07-15 Thread Ethan Furman
On 07/14/2014 11:25 PM, Victor Stinner wrote: Again: remove any garantee about the cache in the definitions of methods, instead copy the doc from os.path and os. Add a global remark saying that most methods don't need any syscall in general, except for symlinks (with follow_symlinks=True). I

Re: [Python-Dev] Remaining decisions on PEP 471 -- os.scandir()

2014-07-15 Thread Paul Moore
On 15 July 2014 13:19, Ben Hoyt wrote: > Hmmm, perhaps. You suggest .full_name implies it's the absolute path, > which isn't true. I don't mind .path, but it kind of sounds like "the > Path object associated with this entry". I think "full_name" is fine > -- it's not "abs_name". Interesting. I ha

Re: [Python-Dev] Remaining decisions on PEP 471 -- os.scandir()

2014-07-15 Thread Ben Hoyt
> I'd *keep DirEntry.lstat() method* regardless of existence of > .stat(*, follow_symlinks=True) method (despite the slight violation of > DRY principle) for readability. `dir_entry.lstat().st_mode` is more > consice than `dir_entry.stat(follow_symlinks=False).st_mode` and the > meaning of lstat is

Re: [Python-Dev] Remaining decisions on PEP 471 -- os.scandir()

2014-07-15 Thread Ben Hoyt
> Sorry, I don't remember who but someone proposed to add the follow_symlinks > parameter in scandir() directly. If the parameter is added to methods, > there is no such issue. Yeah, I think having the DirEntry methods do different things depending on how scandir() was called is a really bad idea

Re: [Python-Dev] Remaining decisions on PEP 471 -- os.scandir()

2014-07-15 Thread Ben Hoyt
> Looks doable. Just make sure the cached entries reflect the > 'follow_symlinks' setting -- so a symlink could end up with both an lstat > cached entry and a stat cached entry. Yes, good point -- basically the functions will use the _stat cache if follow_symlinks=True, otherwise the _lstat cache

Re: [Python-Dev] Remaining decisions on PEP 471 -- os.scandir()

2014-07-15 Thread Nick Coghlan
On 14 Jul 2014 22:50, "Ben Hoyt" wrote: > > In light of that, I propose I update the PEP to basically follow > Victor's model of is_X() and stat() following symlinks by default, and > allowing you to specify follow_symlinks=False if you want something > other than that. > > Victor had one other qu

Re: [Python-Dev] PEP 3121, 384 Refactoring Issues

2014-07-15 Thread Nick Coghlan
On 14 Jul 2014 11:41, "Brett Cannon" wrote: > > > I agree for PEP 3121 which is the initialization/finalization work. The stable ABi is not necessary. So maybe we should re-examine the patches and accept the bits that clean up init/finalization and leave out any ABi-related changes. Martin's rig