This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1: LOAD_FAST <index1> | |
LOAD_CONST <value1> | |
COMPARE_OP <operation1> | |
JUMP_IF_FALSE_OR_POP <return> | |
2: LOAD_FAST <index2> | |
LOAD_CONST <value2> | |
COMPARE_OP <operation2> | |
JUMP_IF_FALSE_OR_POP <return> | |
... repeated for each value except the last one ... | |
N: LOAD_FAST <indexN> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dis import cmp_op | |
from typing import List, NamedTuple, Optional | |
from fast_comparator import Comparison | |
class KeyRange(NamedTuple): | |
exact_value: Optional[bytes] | |
min_value: Optional[bytes] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dis | |
import unittest | |
from humu.storage.impl.fast_comparator import Comparison, makeFastComparator | |
class testFastComparator(unittest.TestCase): | |
def testSimpleComparator(self): | |
# This should make a function | |
# def compareTwo(x1, x2): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dis | |
import io | |
from types import CodeType, FunctionType | |
from typing import Any, Callable, List, NamedTuple, Tuple | |
# Opcodes | |
_LOAD_FAST = dis.opname.index('LOAD_FAST') | |
_LOAD_CONST = dis.opname.index('LOAD_CONST') | |
_COMPARE_OP = dis.opname.index('COMPARE_OP') | |
_JUMP_IF_FALSE_OR_POP = dis.opname.index('JUMP_IF_FALSE_OR_POP') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dis | |
import io | |
from types import CodeType, FunctionType | |
from typing import Any, Callable, List, NamedTuple, Tuple | |
# Opcodes | |
_LOAD_FAST = dis.opname.index('LOAD_FAST') | |
_LOAD_CONST = dis.opname.index('LOAD_CONST') | |
_COMPARE_OP = dis.opname.index('COMPARE_OP') | |
_JUMP_IF_FALSE_OR_POP = dis.opname.index('JUMP_IF_FALSE_OR_POP') |