Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use attached_object in ruby 3.2+. #318

Merged
merged 1 commit into from
Oct 23, 2023

Conversation

alpaca-tc
Copy link
Contributor

@alpaca-tc alpaca-tc commented Sep 15, 2023

In ruby 3.2+, the method #attached_object is available to search for object of the singleton class.
It is more simple and faster than using ObjectSpace.

Before merging:

  • Copy the table printed at the end of the latest benchmark results into the README.md and update this PR
  • If this change merits an update to CHANGELOG.md, add an entry following Keep a Changelog guidelines with semantic versioning

@alpaca-tc alpaca-tc marked this pull request as ready for review September 15, 2023 12:41
@JacobEvelyn
Copy link
Member

Thanks for making this change @alpaca-tc! This looks great. Since we only run code coverage analysis on the Ruby 3.2 tests, would you mind wrapping :nocov: comments around the else block so the code coverage test passes?

@alpaca-tc
Copy link
Contributor Author

Added nocov, sorry if I wrote it wrong as I have never written a comment with nocov.

@JacobEvelyn
Copy link
Member

That's perfect, thanks! ❤️ If you would be willing to:

  • update the README.md with these benchmark results from the latest runs (not sure if you have access to see these: 3.2.2, 2.7.8):
Results using Ruby 3.2.2:

|Method arguments|`Dry::Core`\* (1.0.1)|`Memery` (1.5.0)|
|--|--|--|
|`()` (none)|0.54x|3.62x|
|`(a)`|1.54x|7.74x|
|`(a, b)`|1.29x|5.58x|
|`(a:)`|1.55x|12.37x|
|`(a:, b:)`|1.15x|8.76x|
|`(a, b:)`|1.15x|8.75x|
|`(a, *args)`|0.84x|1.54x|
|`(a:, **kwargs)`|0.79x|2.13x|
|`(a, *args, b:, **kwargs)`|0.69x|1.38x|

\* `Dry::Core`
[may cause incorrect behavior caused by hash collisions](https://github.com/dry-rb/dry-core/issues/63).

Results using Ruby 2.7.8 (because these gems raise errors in Ruby 3.x):

|Method arguments|`DDMemoize` (1.0.0)|`Memoist` (0.16.2)|`Memoized` (1.1.1)|`Memoizer` (1.0.3)|
|--|--|--|--|--|
|`()` (none)|24.22x|2.42x|26.43x|2.70x|
|`(a)`|22.08x|15.19x|22.03x|13.67x|
|`(a, b)`|19.12x|14.01x|18.60x|12.80x|
|`(a:)`|30.21x|24.29x|26.43x|23.11x|
|`(a:, b:)`|27.73x|22.97x|25.11x|21.89x|
|`(a, b:)`|26.87x|22.76x|23.71x|21.26x|
|`(a, *args)`|3.15x|2.30x|3.18x|2.11x|
|`(a:, **kwargs)`|2.89x|2.40x|2.69x|2.28x|
|`(a, *args, b:, **kwargs)`|2.12x|1.82x|1.96x|1.74x|
  • squash your commits into one

I'll merge this and release a new version right away.

@alpaca-tc alpaca-tc force-pushed the use-attached-object branch from b9a6986 to 56f6d6f Compare October 10, 2023 13:30
@codecov
Copy link

codecov bot commented Oct 10, 2023

Codecov Report

Merging #318 (56f6d6f) into main (ed0fb3e) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main      #318   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          177       179    +2     
  Branches        87        88    +1     
=========================================
+ Hits           177       179    +2     
Files Coverage Δ
lib/memo_wise/internal_api.rb 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@alpaca-tc
Copy link
Contributor Author

fixed 👍

@JacobEvelyn JacobEvelyn merged commit 3303feb into panorama-ed:main Oct 23, 2023
12 checks passed
@JacobEvelyn
Copy link
Member

Thanks so much @alpaca-tc and so sorry for the delay! This has now been released in v1.8.0. Thanks for being a contributor!

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