diff options
author | yjqiang <13307130285@fudan.edu.cn> | 2018-09-12 10:07:01 +0800 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2018-09-16 12:14:27 +0200 |
commit | 11bf33264c620684fcae6c248df30c0a444babdf (patch) | |
tree | 973f5c000e32d4a1832a92f085f6f839fd37a3b0 | |
parent | 7619f14036519d19cbfd217823a354635c5c78fc (diff) | |
download | rsa-git-11bf33264c620684fcae6c248df30c0a444babdf.tar.gz |
speedup
"if A and B" if mostly A is True then we should judge B at first
-rw-r--r-- | rsa/key.py | 2 | ||||
-rw-r--r-- | rsa/parallel.py | 2 | ||||
-rw-r--r-- | rsa/pkcs1.py | 2 | ||||
-rw-r--r-- | rsa/pkcs1_v2.py | 2 | ||||
-rw-r--r-- | rsa/prime.py | 2 | ||||
-rw-r--r-- | rsa/randnum.py | 2 |
6 files changed, 6 insertions, 6 deletions
@@ -783,7 +783,7 @@ if __name__ == '__main__': if failures: break - if (count and count % 10 == 0) or count == 1: + if (count % 10 == 0 and count) or count == 1: print('%i times' % count) except KeyboardInterrupt: print('Aborted') diff --git a/rsa/parallel.py b/rsa/parallel.py index edaf6bc..a3fe312 100644 --- a/rsa/parallel.py +++ b/rsa/parallel.py @@ -95,7 +95,7 @@ if __name__ == '__main__': if failures: break - if count and count % 10 == 0: + if count % 10 == 0 and count: print('%i times' % count) print('Doctests done') diff --git a/rsa/pkcs1.py b/rsa/pkcs1.py index b516cec..84f0e3b 100644 --- a/rsa/pkcs1.py +++ b/rsa/pkcs1.py @@ -433,7 +433,7 @@ if __name__ == '__main__': if failures: break - if count and count % 100 == 0: + if count % 100 == 0 and count: print('%i times' % count) print('Doctests done') diff --git a/rsa/pkcs1_v2.py b/rsa/pkcs1_v2.py index d6d2423..5f9c7dd 100644 --- a/rsa/pkcs1_v2.py +++ b/rsa/pkcs1_v2.py @@ -97,7 +97,7 @@ if __name__ == '__main__': if failures: break - if count and count % 100 == 0: + if count % 100 == 0 and count: print('%i times' % count) print('Doctests done') diff --git a/rsa/prime.py b/rsa/prime.py index d8c1f04..3d63542 100644 --- a/rsa/prime.py +++ b/rsa/prime.py @@ -195,7 +195,7 @@ if __name__ == '__main__': if failures: break - if count and count % 100 == 0: + if count % 100 == 0 and count: print('%i times' % count) print('Doctests done') diff --git a/rsa/randnum.py b/rsa/randnum.py index 3c788a5..310acaa 100644 --- a/rsa/randnum.py +++ b/rsa/randnum.py @@ -88,7 +88,7 @@ def randint(maxvalue): if value <= maxvalue: break - if tries and tries % 10 == 0: + if tries % 10 == 0 and tries: # After a lot of tries to get the right number of bits but still # smaller than maxvalue, decrease the number of bits by 1. That'll # dramatically increase the chances to get a large enough number. |