[ruby-core:96782] [Ruby master Feature#8709] Dir.glob should return sorted file list
From:
eregontp@...
Date:
2020-01-11 11:33:35 UTC
List:
ruby-core #96782
Issue #8709 has been updated by Eregon (Benoit Daloze).
Here are some benchmark results in the ruby repository:
```
$ ruby -e 'p Dir["**/*"].size'
12171
$ ruby -rbenchmark -e '10.times { p Benchmark.realtime { Dir["**/*"] } }'
0.017877419999422273
0.015390422999189468
0.015255956001055893
0.015021605999208987
0.015777969998453045
0.015484851002838695
0.016179073001694633
0.015210424000542844
0.015358253996964777
0.014319942998554325
$ ruby -rbenchmark -e '10.times { p Benchmark.realtime { Dir["**/*"].sort } }'
0.017600111998035572
0.017109740001615137
0.017832364999776473
0.01726310600133729
0.018130796997866128
0.01659841600121581
0.018173008000303525
0.017528833999676863
0.017515739000373287
0.01770434499849216
```
So a bit slower but we can likely optimize further if desired.
----------------------------------------
Feature #8709: Dir.glob should return sorted file list
https://bugs.ruby-lang.org/issues/8709#change-83776
* Author: tommorris (Tom Morris)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
On OS X, Dir.glob and Dir[] return an ordered list of files.
On Ubuntu Linux, they do not and one must manually sort them.
Returning a list of files that isn't in order fails the Principle of Least Astonishment.
I attach a unit test to demonstrate ideal behaviour.
---Files--------------------------------
globtest.rb (454 Bytes)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>