4 ms·
That's not really surprising since regex in most languages is PCRE and not really indicative of actual interpreter performance.
by TylerE 6y ago
That's not really surprising since regex in most languages is PCRE and not really indicative of actual interpreter performance.
- cutler 6y agoIf that's the case why is Ruby slower?
- TylerE 6y agoBecause what you’re really measuring is something like how well the block size the interpreter uses for IO matches the underlying os/hardware
- cutler 6y agoIf they are both doing similar things and one is faster that's still significant. So Python's i/o is faster than Ruby's.
- byroot 6y agoYour Ruby snippet is slower for two reasons: - IO.foreach is lazy, but then you call `Array#grep` on it which allocate a huge Array - `grep` populate the "last_match" object, `String#match?` is much faster. Try rifraf's snippet: https://news.ycombinator.com/item?id=24597067 https://news.ycombinator.com/item?id=24597067, it should be as fast as Python.