[Patches] [ python-Patches-895445 ] hmac.HMAC.copy() speedup
SourceForge.net
noreply at sourceforge.net
Sat Mar 20 15:24:22 EST 2004
Patches item #895445, was opened at 2004-02-12 00:28
Message generated for change (Comment added) made by tim_one
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=895445&group_id=5470
Category: Library (Lib)
Group: Python 2.3
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: Trevor Perrin (trevp)
Assigned to: Nobody/Anonymous (nobody)
Summary: hmac.HMAC.copy() speedup
Initial Comment:
Hi,
I'm using python 2.3.2, on WinXP. This is my first
submitted patch, let me know if I'm doing anything
wrong..
The current hmac.HMAC.copy() constructs a new
instance first, then overwrites it. The hmac._strxor()
function called in the constructor is slow.
HMAC is used in protocols like TLS & IPSEC where you
want to MAC each packet or record sent, so you'd want
to construct an HMAC object once, then copy() it for
each record. I'm writing a TLS implementation, and the
patch here gives me ~30% increase in throughput.
Trevor
----------------------------------------------------------------------
>Comment By: Tim Peters (tim_one)
Date: 2004-03-20 15:24
Message:
Logged In: YES
user_id=31435
It's a decent idea -- thanks! The mechanics of the patch
were fine. It's not good to use None as a secret backdoor
argument, since passing a computed None by mistake is a
common program flaw, and getting back an insane HMAC
object then is a poor outcome. So the patch I checked in
uses a different gimmick (a unique module-private object --
such a thing cannot be passed by mistake).
Lib/hmac.py; new revision: 1.8
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=895445&group_id=5470
More information about the Patches
mailing list