Skip to content

Commit 11bf332

Browse files
yjqiangsybrenstuvel
authored andcommitted
speedup
"if A and B" if mostly A is True then we should judge B at first
1 parent 7619f14 commit 11bf332

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

rsa/key.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ def newkeys(nbits, accurate=True, poolsize=1, exponent=DEFAULT_EXPONENT):
783783
if failures:
784784
break
785785

786-
if (count and count % 10 == 0) or count == 1:
786+
if (count % 10 == 0 and count) or count == 1:
787787
print('%i times' % count)
788788
except KeyboardInterrupt:
789789
print('Aborted')

rsa/parallel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def getprime(nbits, poolsize):
9595
if failures:
9696
break
9797

98-
if count and count % 10 == 0:
98+
if count % 10 == 0 and count:
9999
print('%i times' % count)
100100

101101
print('Doctests done')

rsa/pkcs1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def _find_method_hash(clearsig):
433433
if failures:
434434
break
435435

436-
if count and count % 100 == 0:
436+
if count % 100 == 0 and count:
437437
print('%i times' % count)
438438

439439
print('Doctests done')

rsa/pkcs1_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def mgf1(seed, length, hasher='SHA-1'):
9797
if failures:
9898
break
9999

100-
if count and count % 100 == 0:
100+
if count % 100 == 0 and count:
101101
print('%i times' % count)
102102

103103
print('Doctests done')

rsa/prime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def are_relatively_prime(a, b):
195195
if failures:
196196
break
197197

198-
if count and count % 100 == 0:
198+
if count % 100 == 0 and count:
199199
print('%i times' % count)
200200

201201
print('Doctests done')

rsa/randnum.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def randint(maxvalue):
8888
if value <= maxvalue:
8989
break
9090

91-
if tries and tries % 10 == 0:
91+
if tries % 10 == 0 and tries:
9292
# After a lot of tries to get the right number of bits but still
9393
# smaller than maxvalue, decrease the number of bits by 1. That'll
9494
# dramatically increase the chances to get a large enough number.

0 commit comments

Comments
 (0)