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

slight performance increase for graph.all_nodes() #458

Merged
merged 1 commit into from
Feb 25, 2015

Conversation

joernhees
Copy link
Member

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

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

```python
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 joernhees self-assigned this Feb 24, 2015
@joernhees joernhees added this to the rdflib 4.2.1 milestone Feb 24, 2015
joernhees added a commit that referenced this pull request Feb 25, 2015
slight performance increase for graph.all_nodes()
@joernhees joernhees merged commit 127c553 into RDFLib:master Feb 25, 2015
@joernhees joernhees deleted the perf_all_nodes branch February 25, 2015 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant