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

reimplement uuid4 in session #206

Merged
merged 2 commits into from
Sep 26, 2016
Merged

reimplement uuid4 in session #206

merged 2 commits into from
Sep 26, 2016

Conversation

minrk
Copy link
Member

@minrk minrk commented Sep 26, 2016

avoids call-time imports in stdlib uuid, which can cause threading issues with Python import locks.

We don't ever need actual UUIDs, we just want random strings, so we could skip UUID's - formatting.

closes ipython/ipykernel#193

cc @rkern

@rkern
Copy link

rkern commented Sep 26, 2016

Other than the failing type-assertion in the 2.7 tests, LGTM!

avoids call-time imports in stdlib uuid,
which can cause threading issues with Python import locks.

We don't ever need actual UUIDs, we just want random strings,
so we could skip UUID's `-` formatting.
@minrk minrk added this to the 4.5 milestone Sep 26, 2016
"""
buf = os.urandom(16)
return u'-'.join(b2a_hex(x).decode('ascii') for x in (
buf[:4], buf[4:6], buf[6:8], buf[8:10], buf[10:]
Copy link
Member

Choose a reason for hiding this comment

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

Even a random UUID is not just random bytes; there are a couple of type fields in there to indicate what kind of UUID it is.

https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_.28random.29

As you say, we don't really need UUID, just a string that's unique in context. So if we're just going to generate random bytes, let's not call it a uuid or format it like a uuid.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call. Called it new_id, and skipped the uuid-specific layout.

instead of uuid, since it doesn’t implement the uuid spec

and skip uuid layout
@takluyver
Copy link
Member

👍

@minrk minrk merged commit 439981a into jupyter:master Sep 26, 2016
@minrk minrk deleted the uuid4-no-import branch September 26, 2016 15:18
@minrk minrk modified the milestones: 4.5, 5.0 Feb 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Import deadlock with streams
3 participants