Hacker News new | ask | show | jobs
by TylerE 2097 days ago
That's not really surprising since regex in most languages is PCRE and not really indicative of actual interpreter performance.
1 comments

If that's the case why is Ruby slower?
Your 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, it should be as fast as Python.
Because what you’re really measuring is something like how well the block size the interpreter uses for IO matches the underlying os/hardware
If they are both doing similar things and one is faster that's still significant. So Python's i/o is faster than Ruby's.