[ python-Bugs-1618455 ] HMAC can get a 6x performance increase easily

SourceForge.net noreply at sourceforge.net
Tue Dec 19 15:58:56 CET 2006


Bugs item #1618455, was opened at 2006-12-18 18:12
Message generated for change (Comment added) made by bmaurer
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1618455&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Closed
Resolution: Accepted
Priority: 5
Private: No
Submitted By: Ben Maurer (bmaurer)
Assigned to: A.M. Kuchling (akuchling)
Summary: HMAC can get a 6x performance increase easily

Initial Comment:
The attached patch increases the performance of HMAC by a factor of 6. It does so by avoiding useing join/map in the strxor and using a lookup table. It would be faster just to do xor at the string level, but it's not clear that can be done without help from C.

----------------------------------------------------------------------

>Comment By: Ben Maurer (bmaurer)
Date: 2006-12-19 09:58

Message:
Logged In: YES 
user_id=660878
Originator: YES

The performance increase is if you call hmac.new a lot. I did a benchmark
on a relatively small amount of cleartext (50 bytes). This was actually
something I needed to use.

One thing I found -- reusing teh same hmac option helps *ALOT* the hmac
docs don't make it clear how much this will help.

----------------------------------------------------------------------

Comment By: A.M. Kuchling (akuchling)
Date: 2006-12-19 09:16

Message:
Logged In: YES 
user_id=11375
Originator: NO

Thanks for your patch; I've modified it to remove _strxor() completely and
applied the change as rev. 53065.  

When I tried a trivial benchmark, the speed improvement wasn't anywhere
near 6X, and was more like 7%.  The patch is still worth applying because
it also simplifies the code.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1618455&group_id=5470


More information about the Python-bugs-list mailing list