equal
deleted
inserted
replaced
26 |
26 |
27 def _fastsha1(s): |
27 def _fastsha1(s): |
28 # This function will import sha1 from hashlib or sha (whichever is |
28 # This function will import sha1 from hashlib or sha (whichever is |
29 # available) and overwrite itself with it on the first call. |
29 # available) and overwrite itself with it on the first call. |
30 # Subsequent calls will go directly to the imported function. |
30 # Subsequent calls will go directly to the imported function. |
31 try: |
31 if sys.version_info >= (2, 5): |
32 from hashlib import sha1 as _sha1 |
32 from hashlib import sha1 as _sha1 |
33 except ImportError: |
33 else: |
34 from sha import sha as _sha1 |
34 from sha import sha as _sha1 |
35 global _fastsha1, sha1 |
35 global _fastsha1, sha1 |
36 _fastsha1 = sha1 = _sha1 |
36 _fastsha1 = sha1 = _sha1 |
37 return _sha1(s) |
37 return _sha1(s) |
38 |
38 |