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

Optimizations #83

Merged
merged 3 commits into from
Jun 8, 2017
Merged

Optimizations #83

merged 3 commits into from
Jun 8, 2017

Conversation

kckennylau
Copy link
Contributor

No description provided.

@Mego
Copy link
Owner

Mego commented Jun 8, 2017

Make the change on line 731 like I mentioned in the comment, and this should be good to merge, assuming the CI build succeeds.

@codecov-io
Copy link

codecov-io commented Jun 8, 2017

Codecov Report

Merging #83 into master will decrease coverage by 0.16%.
The diff coverage is 67.34%.

@@            Coverage Diff             @@
##           master      #83      +/-   ##
==========================================
- Coverage   87.19%   87.02%   -0.17%     
==========================================
  Files           7        7              
  Lines        1616     1619       +3     
  Branches      314      295      -19     
==========================================
  Hits         1409     1409              
- Misses        151      154       +3     
  Partials       56       56

@kckennylau
Copy link
Contributor Author

I've changed from copy import copy as _copy to from copy import deepcopy as _copy.

@@ -728,7 +728,7 @@ def dupe_each_n_fn(srs):
tmp = []
while srs.stack:
b = srs.pop()
tmp = [b]*a + tmp
tmp = [copy.deepcopy(b) for _ in range(a)] + tmp
Copy link
Owner

@Mego Mego Jun 8, 2017

Choose a reason for hiding this comment

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

This wasn't necessary - copy in the global scope is a wrapper around copy.copy (well, now, copy.deepcopy) that properly handles generators. It should be tmp = [copy(b) for _ in range(a)] + tmp.

@kckennylau
Copy link
Contributor Author

I just noticed that you have an as_list function that you wrote yourself. Should I replace all occurrences of list with as_list?

@kckennylau
Copy link
Contributor Author

Actually, I shouldn't. as_list wraps non-iterables.

@Mego
Copy link
Owner

Mego commented Jun 8, 2017

No, as_list wraps singletons, and deeply converts iterables to lists. It's very expensive, and only really needed when working with generators that can yield other generators.

@Mego Mego merged commit 413b403 into Mego:master Jun 8, 2017
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