Skip to content

Conversation

@byroot
Copy link

@byroot byroot commented Jun 24, 2025

By doing most of <=> can be implemented in Ruby, it's really only the path comparison that benefit from C.

@eregon

eregon and others added 12 commits June 18, 2025 22:07
* This is just before methods started to be moved from Ruby code to the C extension.
* BTW, in the ruby/pathname repository there was no pathname.rb before that commit.
* This means it's only additions in lib/pathname.rb and zero removals.
* The <=> implementation in the extension is much faster, so is kept.
* The other methods are actually faster in Ruby than in C,
  because rb_funcall() and rb_ivar_get() in C code have no inline cache,
  but method calls and `@path` have inline caches in Ruby code.
  https://railsatscale.com/2023-08-29-ruby-outperforms-c/ is an explanation
  of that (though it was known well before that).
By doing most of `<=>` can be implemented in Ruby, it's
really only the path comparison that benefit from C.
@eregon eregon force-pushed the pure-ruby-pathname branch 2 times, most recently from b868d69 to c96b559 Compare July 15, 2025 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants