Skip to content

Deprecate comparing Gem::Version objects with strings#9085

Merged
hsbt merged 2 commits intoruby:masterfrom
tenderlove:deprecate-str-cmp
Nov 21, 2025
Merged

Deprecate comparing Gem::Version objects with strings#9085
hsbt merged 2 commits intoruby:masterfrom
tenderlove:deprecate-str-cmp

Conversation

@tenderlove
Copy link
Copy Markdown
Member

Comparing version objects is a huge bottleneck in dependency solvers (like inside Bundler). I would like to make comparing version objects cheaper. Right now we support comparing version objects with strings by trying to coerce the string to a version. So for example:

Gem::Version.new("1") <=> "12"

I would like to deprecate and remove support for this feature so that we can reduce the overhead of def <=>.

I'm not sure what version of RubyGems we could remove this from though.

@tenderlove tenderlove force-pushed the deprecate-str-cmp branch 4 times, most recently from 27bbcb4 to 704e8ae Compare November 16, 2025 23:33
Comparing version objects is a huge bottleneck in dependency solvers
(like inside Bundler).  I would like to make comparing version objects
cheaper.  Right now we support comparing version objects with strings by
trying to coerce the string to a version.  So for example:

```ruby
Gem::Version.new("1") <=> "12"
```

I would like to deprecate and remove support for this feature so that we
can reduce the overhead of `def <=>`.

I'm not sure what version of RubyGems we could remove this from though.
Copy link
Copy Markdown
Member

@hsbt hsbt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may disable that feature about 3-4 years later.

@hsbt hsbt merged commit 81b7602 into ruby:master Nov 21, 2025
74 of 76 checks passed
hsbt added a commit that referenced this pull request Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants