Re:How Ruby is beating Python in the battle for the Soul of ...
by jbert on Monday October 03, 2011 @09:33AM
(#3066190)
> A lot uglier, but you can do a one liner ...
Yeah, but that one-liner reads the whole file. 'tail' can be more clever (and is). 'strace' output:
open("a", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=545975512, ...}) = 0
lseek(3, 0, SEEK_CUR) = 0
lseek(3, 0, SEEK_END) = 545975512
lseek(3, 545972224, SEEK_SET) = 545972224
read(3, "tu 11.04 \\n \\l\n\nUbuntu 11.04 \\n "..., 3288) = 3288
'tail' is seeking to the end, then reading backwards.The point being, these 'little tools' can contain important optimisations - they aren't necessarily equivalent to a naive reimplementation.
Re:How Ruby is beating Python in the battle for the Soul of ...
by lloeki on Monday October 03, 2011 @11:06AM
(#3066537)
Reminds me on that article on GNU grep doing some speedy magic: http://lists.freebsd.org/pipermail/freebsd-current/2010-Augu...
Here's an (ugly) one liner that shows the biggest tables in a MySQL database:
You can probably come up with something more clever, but I barely gave that one any thought.