-
Notifications
You must be signed in to change notification settings - Fork 564
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
Fixed bnode collision bug. #506
Conversation
@@ -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)])) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed bnode collision bug, fixes #494
Fix for #494.