def _period_array_cmp(cls, op):
opname = '<STR_LIT>'.format(name=op.__name__)<EOL>nat_result = opname == '<STR_LIT>'<EOL>def wrapper(self, other):<EOL><INDENT>op = getattr(self.asi8, opname)<EOL>if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)):<EOL><INDENT>return NotImplemented<EOL><DEDENT>if is_list_like(other) and len(other) != len(self):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if isinstance(other, Period):<EOL><INDENT>self._check_compatible_with(other)<EOL>result = op(other.ordinal)<EOL><DEDENT>elif isinstance(other, cls):<EOL><INDENT>self._check_compatible_with(other)<EOL>result = op(other.asi8)<EOL>mask = self._isnan | other._isnan<EOL>if mask.any():<EOL><INDENT>result[mask] = nat_result<EOL><DEDENT>return result<EOL><DEDENT>elif other is NaT:<EOL><INDENT>result = np.empty(len(self.asi8), dtype=bool)<EOL>result.fill(nat_result)<EOL><DEDENT>else:<EOL><INDENT>other = Period(other, freq=self.freq)<EOL>result = op(other.ordinal)<EOL><DEDENT>if self._hasnans:<EOL><INDENT>result[self._isnan] = nat_result<EOL><DEDENT>return result<EOL><DEDENT>return compat.set_function_name(wrapper, opname, cls)<EOL>
Wrap comparison operations to convert Period-like to PeriodDtype