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

Fixed bnode collision bug. #506

Merged
merged 1 commit into from
Aug 10, 2015

Conversation

jpmccu
Copy link
Contributor

@jpmccu jpmccu commented Aug 9, 2015

Fix for #494.

@@ -290,7 +292,7 @@ def _initial_color(self):

def _individuate(self, color, individual):
new_color = list(color.color)
new_color.append((len(color.nodes)))
new_color.append(tuple([len(color.nodes)]))
Copy link
Member

Choose a reason for hiding this comment

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

sorry for not spotting this one before :-/

could also be written as new_color.append((len(color.nodes),)), which is a bit faster, but maybe premature optimization:

In [1]: %timeit tuple([1337])
The slowest run took 5.53 times longer than the fastest. This could mean that an intermediate result is being cached
1000000 loops, best of 3: 345 ns per loop

In [2]: %timeit (1337,)
The slowest run took 47.08 times longer than the fastest. This could mean that an intermediate result is being cached
10000000 loops, best of 3: 25.3 ns per loop

Copy link
Member

Choose a reason for hiding this comment

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

On Mon, 10 Aug 2015 10:33:29 -0700, Jörn Hees [email protected] said:

> could also be written as
> `new_color.append((len(color.nodes),))`, which is a bit faster,
> but maybe premature optimization:

Creating a value with the right datatype instead of creating one with
the wrong datatype and then converting it isn't optimisation, it's
just doing things correctly.

Or so I think anyways...

-w

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wouldn't object to the change. I couldn't remember the syntax for a single-element tuple.

Copy link
Member

Choose a reason for hiding this comment

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

@wwaites: well, the double bracket removal is one of the tripping stones in python, so i can somehow understand why some people prefer (tuple([...])) instead of ((...,)). Without seeing it as much of a problem i still changed it in b8df01f ;)

joernhees added a commit that referenced this pull request Aug 10, 2015
@joernhees joernhees merged commit 3e6d754 into RDFLib:fix_canonicalization Aug 10, 2015
@joernhees joernhees added this to the rdflib 4.2.1 milestone Aug 10, 2015
@joernhees joernhees added bug Something isn't working in-resolution labels Aug 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working in-resolution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants