Merge lp:~gz/bzr/trivial_urandom_uncalled into lp:bzr
Status: | Merged |
---|---|
Approved by: | Jelmer Vernooij |
Approved revision: | no longer in the source branch. |
Merged at revision: | 6423 |
Proposed branch: | lp:~gz/bzr/trivial_urandom_uncalled |
Merge into: | lp:bzr |
Diff against target: |
32 lines (+9/-12) 1 file modified
bzrlib/osutils.py (+9/-12) |
To merge this branch: | bzr merge lp:~gz/bzr/trivial_urandom_uncalled |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jelmer Vernooij (community) | Approve | ||
Review via email: mp+87396@code.launchpad.net |
Commit message
Simplify wrapping of os.urandom done by osutils
Description of the change
Peel back some of the layering around os.urandom done by osutils at module start time. It's worth avoiding reading the one byte to check the function works on windows, as the first call does expensive initialisation, notably advapi32.dll needs loading. That makes this one call account for 50-100ms on my windows box, where a simple command takes in the region of 400ms on hot caches.
With --profile-imports the change is from:
143.5 103.6 ++ [osutils]bzrlib @ bzrlib.plugin:36
To:
38.7 4.4 ++ [osutils]bzrlib @ bzrlib.plugin:36
The various users of osutils.rand_chars (fancy_rename, lockdir) mean commands that do real work will still need to pay this at a later stage.
Various notes:
* AttributeError from accessing 'urandom' on os not needed since Python 2.4
* NotImplementedError from nt.urandom not an issue with any supported windows versions
* Wrapping /dev/urandom serves no purpose since Python 2.4
* isinstance(
Are there in fact any circumstances in which /dev/urandom will not be available that we want to support, or should I just go all the way and remove the Mersenne Twister fallback as well?
> Are there in fact any circumstances in which /dev/urandom will not be available that we want to support, or should I just go all the way and remove the Mersenne Twister fallback as well?
I have no idea what you mean by "the Mersene Twister fallback". Other than that, I think this is a reasonable change.