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

replace clone to clone_shallow and copy only as much as you need attributes. #618

Closed

Conversation

higumachan
Copy link

@higumachan higumachan commented Jul 30, 2023

Resolves: python-poetry#8250

  • Added tests for changed code.
  • Updated documentation for changed code.

Description

This change was made under the assumption that if the tests pass, there should be no problem. However, just replacing the clone with a shallow copy caused several tests to fail, so I made "one level deeper" copies sufficient to fix those tests.

I understand that there is a trade-off with code maintainability regarding this change, so I would appreciate some feedback.

If we are to implement this while ensuring future changeability, I think we could solve this by creating code similar to Cow (Copy on Write).

Thanks.

@mtkennerly

This comment was marked as off-topic.

@dimbleby
Copy link
Contributor

dimbleby commented Aug 8, 2023

@mtkennerly you have misunderstood this MR, it has nothing at all to do with git clone

@mtkennerly
Copy link

Ah, sorry, you're absolutely right. Carry on 😅

@sonarcloud
Copy link

sonarcloud bot commented Sep 10, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link

sonarcloud bot commented Nov 7, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@eamanu
Copy link
Contributor

eamanu commented Nov 13, 2023

Did you run a profiler to know if this fix the issue?

@@ -481,7 +481,8 @@ def without_optional_dependency_groups(self: T) -> T:
"""
Returns a clone of the package without optional dependency groups.
"""
package = self.clone()
package = self.clone_shallow()
package._dependency_groups = package._dependency_groups.copy()
Copy link
Contributor

Choose a reason for hiding this comment

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

a little comment explaining why we are copying the package._depndency_groups wouldbe great

@radoering
Copy link
Member

Superseded by #663.

@radoering radoering closed this Jan 27, 2024
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.

Proportion of Time Spent on Cloning is Significant during poetry lock --no-update
5 participants