[MERGE] rand_chars() optimization
Marius Gedminas
marius at pov.lt
Tue Mar 13 18:50:48 GMT 2007
On Sun, Mar 11, 2007 at 04:39:43PM +0300, Dmitry Vasiliev wrote:
> >I suspect it might be a bit faster if you used a string rather than a
> >dict here:
> >
> > _rand_chars_map = ALNUM * (255 / len(ALNUM) + 1)
>
> But how it may helps to make rand_chars() any faster? With
> _rand_chars_map as a dict you just can do later _rand_chars_map[raw_byte].
You can do the same with a string, only instead of a hash table lookup
that would translate to an array reference.
Uh, that's assuming raw_byte is actually a byte (int) and not a char.
If it's a char, then my suggestion doesn't make sense (but then I
suggest that the variable might be misnamed).
Marius Gedminas
--
There's an old story about the person who wished his computer were as easy to
use as his telephone. That wish has come true, since I no longer know how to
use my telephone.
-- Bjarne Stroustrup
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070313/6a05229b/attachment.pgp
More information about the bazaar
mailing list