On 2016-12-06, Chris Angelico <ros...@gmail.com> wrote: > On Tue, Dec 6, 2016 at 10:56 PM, BartC <b...@freeuk.com> wrote: >> In that directory (which was on Windows but accessible via a virtual Linux), >> typing any Linux command followed by * would have required all 3.4 million >> directory entries to be accessed in order to build a 3.4 million-element >> argv list. I've no idea how long that would have taken. > > I just asked Python to build me a 4-million-element list, and it took > no visible time - a small fraction of a second. Don't be afraid of > large argument lists. We're not writing 8088 Assembly Language > programs in 64KB of working memory here.
To be fair, literally just now I couldn't run the command I wanted to: sed -i -e 's/foo/bar/g' /dir/ectory/*.txt because there were 300,000 files matching the glob, and 'sed' can't cope with that many command-line arguments. I had to do this instead: find /dir/ectory -name '*.txt' -exec sed -i -e 's/foo/bar/g' {} \; (Yes, I could also have done something with 'xargs' instead, which would've been slower to write and quicker to run.) However please don't take that to mean I agree with BartC - he's clearly just reacting with instinctive hostility to the unknown. -- https://mail.python.org/mailman/listinfo/python-list