Changeset 7170


Ignore:
Timestamp:
Jun 10, 2009, 12:56:26 PM (15 years ago)
Author:
rwilson
Message:

Changed safe_crc() to use suggested method.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/numpy/anuga/utilities/system_tools.py

    r7148 r7170  
    244244    """64 bit safe crc computation.
    245245
    246        See Guido's 64 bit fix at http://bugs.python.org/issue1202           
     246    See http://docs.python.org/library/zlib.html#zlib.crc32:
     247
     248        To generate the same numeric value across all Python versions
     249        and platforms use crc32(data) & 0xffffffff.
    247250    """
    248251
    249252    from zlib import crc32
    250     import os
    251 
    252     x = crc32(string)
    253        
    254     if os.name == 'posix' and os.uname()[4] in ['x86_64', 'ia64']:
    255         crcval = x - ((x & 0x80000000) << 1)
    256     else:
    257         crcval = x
    258        
    259     return crcval
     253
     254    return crc32(string) & 0xffffffff
    260255
    261256
Note: See TracChangeset for help on using the changeset viewer.