simplify the implementation
@@ -1474,10 +1474,7 @@ class Operator(object):
paulis.
"""
if self._paulis is not None:
- new_paulis = []
- for pauli in self._paulis:
- if pauli[0] != 0:
- new_paulis.append(pauli)
+ new_paulis = [pauli for pauli in self._paulis if pauli[0] != 0]
self._paulis = new_paulis
self._paulis_table = {pauli[1].to_label(): i for i, pauli in enumerate(self._paulis)}
