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

Fixed a bug that overwrote existing self.extended method definitions. #324

Merged
merged 1 commit into from
Jan 24, 2024

Conversation

alpaca-tc
Copy link
Contributor

@alpaca-tc alpaca-tc commented Jan 17, 2024

There is a hack that dynamically defines self.extended when memo_wise is called, but there was a bug that did not consider the case where an existing self.extended existed, so this has been fixed.

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

Copy link

codecov bot commented Jan 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (aae31f2) 100.00% compared to head (20fe5fe) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #324   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          179       183    +4     
  Branches        88        88           
=========================================
+ Hits           179       183    +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JacobEvelyn
Copy link
Member

Thanks @alpaca-tc ! This looks great to me.

Would you mind rebasing your branch on top of the latest main, and while you're at it updating the README.md benchmark results to these from the CI run for this PR:

|Method arguments|`Dry::Core`\* (1.0.1)|`Memery` (1.5.0)|
|--|--|--|
|`()` (none)|0.59x|3.65x|
|`(a)`|1.49x|8.38x|
|`(a, b)`|1.21x|6.55x|
|`(a:)`|1.43x|13.14x|
|`(a:, b:)`|1.20x|10.32x|
|`(a, b:)`|1.18x|10.10x|
|`(a, *args)`|0.79x|1.61x|
|`(a:, **kwargs)`|0.75x|1.97x|
|`(a, *args, b:, **kwargs)`|0.67x|1.37x|
|Method arguments|`DDMemoize` (1.0.0)|`Memoist` (0.16.2)|`Memoized` (1.1.1)|`Memoizer` (1.0.3)|
|--|--|--|--|--|
|`()` (none)|23.10x|2.28x|23.77x|2.69x|
|`(a)`|21.57x|14.28x|20.61x|12.05x|
|`(a, b)`|19.05x|13.55x|17.83x|11.68x|
|`(a:)`|30.29x|23.54x|25.22x|21.69x|
|`(a:, b:)`|27.79x|22.83x|23.78x|21.08x|
|`(a, b:)`|26.61x|21.40x|21.63x|19.81x|
|`(a, *args)`|3.16x|2.26x|3.08x|1.97x|
|`(a:, **kwargs)`|2.74x|2.25x|2.47x|2.10x|
|`(a, *args, b:, **kwargs)`|2.18x|1.84x|1.93x|1.73x|

@JacobEvelyn
Copy link
Member

Actually it looks like GitHub gives me permission to edit your branch so I'm just making those changes. Hope that's okay!

@JacobEvelyn
Copy link
Member

@ms-ati would love your review here! (And also #326 )

instance = klass.new
instance.extend(module_with_memo)

expect(instance.instance_variable_get(:@extended_called)).to be(true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hello @alpaca-tc thank you for this!

Can we add a test asserting, in addition to the fact that we call the previously defined Module#extended, that we also are actually memoizing the call to no_args? I suspect that was intended by maybe not finished?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added and force-pushed 👍

There is a hack that dynamically defines self.extended when memo_wise is called, but there was a bug that did not consider the case where an existing self.extended existed, so this has been fixed.
@JacobEvelyn JacobEvelyn merged commit c848377 into panorama-ed:main Jan 24, 2024
12 checks passed
Copy link
Contributor

@ms-ati ms-ati left a comment

Choose a reason for hiding this comment

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

Thank you so much! LGTM

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.

3 participants