Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

performance of subsets() #71

Open
asbisen opened this issue Sep 20, 2016 · 2 comments
Open

performance of subsets() #71

asbisen opened this issue Sep 20, 2016 · 2 comments

Comments

@asbisen
Copy link

asbisen commented Sep 20, 2016

Cross referencing a possible performance issue with Iterators.subsets() and Combinatorics.combinations() that I posted in Combinatorics.jl JuliaMath/Combinatorics.jl#30

The performance of subsets() seems to be ~2x slower than pure python Itertools. Sample code to reproduce is in the original post referenced above.

# with Iterators.subsets()
1.164676 seconds (47.23 M allocations: 1.830 GB, 14.97% gc time)

# with Combinatorics.combinations()
1.597081 seconds (56.66 M allocations: 2.814 GB, 15.08% gc time)

# In Pure Python itertools.
Elapsed time 0.5022 seconds
@iamed2
Copy link
Collaborator

iamed2 commented Sep 20, 2016

Alright, I have a few improvements. PR coming soon. I haven't beat Python, but I've come within a more acceptable margin.

@iamed2
Copy link
Collaborator

iamed2 commented Sep 22, 2016

The reason the Python code is so fast is it uses the reference counter directly to reclaim memory in cases where the item generated is used and then discarded (a common pattern). Unfortunately, that can't be done here. I'm not sure what the best way forward is, but #73 should help a little bit.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants