diff --git a/_lz4.py b/_lz4.py index f6a3965..254e515 100644 --- a/_lz4.py +++ b/_lz4.py @@ -12,8 +12,15 @@ except ImportError: xrange = range - def byte2int(_bytes): - return ord(_bytes[0]) + # If we're running Python 3 or newer, we must + # define byte2int differently than with Python 2 + import sys + if sys.version_info[0] >= 3: + import operator + byte2int = operator.itemgetter(0) + else: + def byte2int(_bytes): + return ord(_bytes[0]) class CorruptError(Exception): pass