iota/crypto/pycurl.py
def _transform(self):
        # type: () -> None
        """
        Transforms internal state.
        """
        # Copy some values locally so we can avoid global lookups in the
        # inner loop.
        #
        # References:
        #
        # - https://wiki.python.org/moin/PythonSpeed/PerformanceTips#Local_Variables
        state_length = STATE_LENGTH
        truth_table = TRUTH_TABLE

        # Operate on a copy of ``self._state`` to eliminate dot lookups
        # in the inner loop.
        #
        # References:
        #
        # - https://wiki.python.org/moin/PythonSpeed/PerformanceTips#Avoiding_dots...
        # - http://stackoverflow.com/a/2612990/
        prev_state = self._state[:]
        new_state = prev_state[:]

        # Note: This code looks significantly different from the C
        # implementation because it has been optimized to limit the
        # number of list item lookups (these are relatively slow in
        # Python).
        index = 0
        for _ in range(NUMBER_OF_ROUNDS):
            prev_trit = prev_state[index]

            for pos in range(state_length):
                index += (364 if index < 365 else -365)

                new_trit = prev_state[index]

                new_state[pos] = truth_table[prev_trit + (3 * new_trit) + 4]

                prev_trit = new_trit

            prev_state = new_state
            new_state = new_state[:]

        self._state = new_state
def _transform(self):
        # type: () -> None
        """
        Transforms internal state.
        """
        # Copy some values locally so we can avoid global lookups in the
        # inner loop.
        #
        # References:
        #
        # - https://wiki.python.org/moin/PythonSpeed/PerformanceTips#Local_Variables
        state_length = STATE_LENGTH
        truth_table = TRUTH_TABLE

        # Operate on a copy of ``self._state`` to eliminate dot lookups
        # in the inner loop.
        #
        # References:
        #
        # - https://wiki.python.org/moin/PythonSpeed/PerformanceTips#Avoiding_dots...
        # - http://stackoverflow.com/a/2612990/
        prev_state = self._state[:]
        new_state = prev_state[:]

        # Note: This code looks significantly different from the C
        # implementation because it has been optimized to limit the
        # number of list item lookups (these are relatively slow in
        # Python).
        index = 0
        for _ in range(NUMBER_OF_ROUNDS):
            prev_trit = prev_state[index]

            for pos in range(state_length):
                index += (364 if index < 365 else -365)

                new_trit = prev_state[index]

                new_state[pos] = truth_table[prev_trit + (3 * new_trit) + 4]

                prev_trit = new_trit

            prev_state = new_state
            new_state = new_state[:]

        self._state = new_state
def _transform ( self ) : # type: () -> None # Copy some values locally so we can avoid global lookups in the # inner loop. # # References: # # - https://wiki.python.org/moin/PythonSpeed/PerformanceTips#Local_Variables state_length = STATE_LENGTH truth_table = TRUTH_TABLE # Operate on a copy of ``self._state`` to eliminate dot lookups # in the inner loop. # # References: # # - https://wiki.python.org/moin/PythonSpeed/PerformanceTips#Avoiding_dots... # - http://stackoverflow.com/a/2612990/ prev_state = self . _state [ : ] new_state = prev_state [ : ] # Note: This code looks significantly different from the C # implementation because it has been optimized to limit the # number of list item lookups (these are relatively slow in # Python). index = 0 for _ in range ( NUMBER_OF_ROUNDS ) : prev_trit = prev_state [ index ] for pos in range ( state_length ) : index += ( 364 if index < 365 else - 365 ) new_trit = prev_state [ index ] new_state [ pos ] = truth_table [ prev_trit + ( 3 * new_trit ) + 4 ] prev_trit = new_trit prev_state = new_state new_state = new_state [ : ] self . _state = new_state
Transforms internal state.
Transforms internal state .