Skip to content

Comments

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

Closed
higumachan wants to merge 4 commits intopython-poetry:mainfrom
higumachan:refactor/remove_over_copy
Closed

replace clone to clone_shallow and copy only as much as you need attributes.#618
higumachan wants to merge 4 commits intopython-poetry:mainfrom
higumachan:refactor/remove_over_copy

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 😅

@sonarqubecloud
Copy link

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

@sonarqubecloud
Copy link

sonarqubecloud 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?

"""
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