-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pyca rightfully performs consistency checks when importing keys and these operations are rather expensive. So cache keys once generated so that repeated uses of the same JWK do not incur undue cost of reloading the keys from scratch for each subsequent operation. with a simple test by hand: $ python >>> from jwcrypto import jwk >>> def test(): ... key = jwk.JWK.generate(kty='RSA', size=2048) ... for i in range(1000): ... k = key._get_private_key() ... >>> import timeit Before the patch: >>> print(timeit.timeit("test()", setup="from __main__ import test", number=10)) 35.80328264506534 After the patch: >>> print(timeit.timeit("test()", setup="from __main__ import test", number=10)) 0.9109518649056554 Resolves #243 Signed-off-by: Simo Sorce <simo@redhat.com>
- Loading branch information
Showing
1 changed file
with
73 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters