def append(self, moment_or_operation: _MOMENT_OR_OP) -> int:
        """Find placement for moment/operation and update cache.

        Determines the placement index of the provided operation, assuming
        EARLIEST (append) strategy, and assuming that the internal cache
        correctly represents the circuit. It then updates the cache and returns
        the placement index.

        Args:
            moment_or_operation: The moment or operation to append.

        Returns:
            The index at which the moment/operation should be placed.
        """
        # Identify the index of the moment to place this into.
        index = get_earliest_accommodating_moment_index(
            moment_or_operation,
            self._qubit_indices,
            self._mkey_indices,
            self._ckey_indices,
            self._length,
        )
        self._length = max(self._length, index + 1)
        return index
Find placement for moment/operation and update cache.

        Determines the placement index of the provided operation, assuming
        EARLIEST (append) strategy, and assuming that the internal cache
        correctly represents the circuit. It then updates the cache and returns
        the placement index.

        Args:
            moment_or_operation: The moment or operation to append.

        Returns:
            The index at which the moment/operation should be placed.
        
cirq-core/cirq/circuits/circuit.py