slight performance increase for graph.all_nodes() by joernhees · Pull Request #458 · RDFLib/rdflib (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation0 Commits1 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

joernhees

set.update() seems to be faster than union and we can save the set
creation overhead:

In [1]: %timeit s = set(range(1000)) ; s.update(range(10000)) 1000 loops, best of 3: 419 µs per loop

In [2]: %timeit s = set(range(1000)) ; s.update(set(range(10000))) 1000 loops, best of 3: 584 µs per loop

In [3]: %timeit s = set(range(1000)) ; s.union(set(range(10000))) 1000 loops, best of 3: 610 µs per loop

@joernhees

set.update() seems to be faster than union and we can save the set creation overhead:

In [1]: %timeit s = set(range(1000)) ; s.update(range(10000))
1000 loops, best of 3: 419 µs per loop

In [2]: %timeit s = set(range(1000)) ; s.update(set(range(10000)))
1000 loops, best of 3: 584 µs per loop

In [3]: %timeit s = set(range(1000)) ; s.union(set(range(10000)))
1000 loops, best of 3: 610 µs per loop

joernhees added a commit that referenced this pull request

Feb 25, 2015

@joernhees

slight performance increase for graph.all_nodes()

This was referenced

Jan 16, 2017

This was referenced

Mar 16, 2017

1 participant

@joernhees