This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author palaviv
Recipients ethan.furman, loewis, palaviv, rhettinger, serhiy.storchaka
Date 2016-04-29.08:42:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1461919345.89.0.202442163284.issue26860@psf.upfronthosting.co.za>
In-reply-to
Content
In regard to Raymond`s points I agree with Serhiy`s comments.

As for Serhiy`s doubts:

> 3. Using namedtuple is slower and consumes more memory than using tuple. Even for FS-related operation like os.walk() this can matter. A lot of code is optimized for exact tuples, with namedtuple this optimization is lost.

I did some testing on my own PC:
./python -m timeit -s "from os import walk"  "for x in walk('Lib'): pass"

Regular tuple: 7.53 msec
Named tuple: 7.66 msec

> 4. New names (dirpath, dirnames, filenames) are questionable. Why not use undersores (dir_names)? "dir" in dirpath refers to the current proceeded directory, but "dir" in dirnames refers to it's subdirectories. Currently you are free to use short names (root, dirs, files) from examples or what you prefer, but with namedtuple you are sticked with standard names forever. There are no names that satisfy everybody.

I agree that there will be no names that will satisfy everybody but I think the names that are currently in the documentation are the most trivial choice.

As for points 1,2,5 this feature doesn`t break any of the old walk API.

One more point I would like input on is the testing. I can remove the walk method from the WalkTests, FwalkTests classes and use the new named tuple attributes in the tests. Do you think its better or should we keep the tests with the old API (access using indexes)?
History
Date User Action Args
2016-04-29 08:42:25palavivsetrecipients: + palaviv, loewis, rhettinger, ethan.furman, serhiy.storchaka
2016-04-29 08:42:25palavivsetmessageid: <1461919345.89.0.202442163284.issue26860@psf.upfronthosting.co.za>
2016-04-29 08:42:25palavivlinkissue26860 messages
2016-04-29 08:42:24palavivcreate