Tag Info

New answers tagged

1

I don't do the whole mac thing anymore, so I don't have anything to test with, but in the quest to get this working on FreeBSD, I managed to figure out how to get this working from ports. I recall OSX has stuff like brew and macports - Try installing the GNU coreutils from this if you really want dircolors to work. I also had to set an alias for dircolors to ...


0

Robustness reasons one may want a copy to take place to protect against data "loss". We don't know that's the reason, but the bad things that can happen are limited to destruction of media. Most all block devices will have some form of corruption identification(crc), if not forward error correction(parity). Not for performance reasons. CoW happens when ...


1

For displaying the current directory bash keeps some internal state that doesn't necessarily corresponds to the actual (shortest) path to the current directory. This helps in keeping the path if you cd through soft links. The cd // (but also when doing e.g. cd //tmp) do not seem to trigger a sanitization of the internal path displayed by pwd, but more than ...


15

Izkata's comment revealed the answer: locale-specific comparisons. The sort command uses the locale indicated by the environment, whereas Python defaults to a byte order comparison. Comparing UTF-8 strings is harder than comparing byte strings. $ time (LC_ALL=C sort <numbers.txt >s2.txt) real 0m5.485s user 0m14.028s sys 0m0.404s How about ...


7

This is more of an extra analysis than an actual answer but it does seem to vary depending on the data being sorted. First, a base reading: $ printf "%s\n" {1..1000000} > numbers.txt $ time python sort.py <numbers.txt >s1.txt real 0m0.521s user 0m0.216s sys 0m0.100s $ time sort <numbers.txt >s2.txt real 0m3.708s user ...


5

Both of the implementations are in C, so a level playing field there. Coreutils sort apparently uses the mergesort algorithm. Mergesort does a fixed number of comparisons which increases logarithmically to the input size, i.e. big O(n log n). Python's sort uses a unique hybrid merge/insertion sort, timsort, which will do a variable number of comparisons ...



Top 50 recent answers are included