# Buggy code
def isin(comps, values):
    """
    Compute the isin boolean array

    Parameters
    ----------
    comps: array-like
    values: array-like

    Returns
    -------
    boolean array same length as comps
    """

    if not is_list_like(comps):
        raise TypeError(
            "only list-like objects are allowed to be passed"
            " to isin(), you passed a "
            "[{0}]".format(type(comps).__name__)
        )
    if not is_list_like(values):
        raise TypeError(
            "only list-like objects are allowed to be passed"
            " to isin(), you passed a "
            "[{0}]".format(type(values).__name__)
        )

    if not isinstance(values, (ABCIndex, ABCSeries, np.ndarray)):
        values = lib.list_to_object_array(list(values))

    comps, dtype, _ = _ensure_data(comps)
    values, _, _ = _ensure_data(values, dtype=dtype)

    # GH11232
    # work-around for numpy < 1.8 and comparisions on py3
    # faster for larger cases to use np.in1d
    f = lambda x, y: htable.ismember_object(x, values)
    if (_np_version_under1p8 and compat.PY3) or len(comps) > 1000000:
        f = lambda x, y: np.in1d(x, y)
    elif is_integer_dtype(comps):
        try:
            values = values.astype("int64", copy=False)
            comps = comps.astype("int64", copy=False)
            f = lambda x, y: htable.ismember_int64(x, y)
        except (TypeError, ValueError):
            values = values.astype(object)
            comps = comps.astype(object)

    elif is_float_dtype(comps):
        try:
            values = values.astype("float64", copy=False)
            comps = comps.astype("float64", copy=False)
            checknull = isnull(values).any()
            f = lambda x, y: htable.ismember_float64(x, y, checknull)
        except (TypeError, ValueError):
            values = values.astype(object)
            comps = comps.astype(object)

    return f(comps, values)


# Traceback (TypeError)
In [2]: i = pd.Series(list('abcdefghijk'*10**5))

In [3]: alt = [-1, 'AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GR']*6

In [4]: res = i[:10**6].isin(alt)

In [5]: res = i[:10**6+1].isin(alt)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-f3e21d855671> in <module>()
----> 1 res = i[:10**6+1].isin(alt)

/home/pietro/nobackup/repo/pandas/pandas/core/series.py in isin(self, values)
2458
2459         """
-> 2460         result = algorithms.isin(_values_from_object(self), values)
2461         return self._constructor(result, index=self.index).__finalize__(self)
2462

/home/pietro/nobackup/repo/pandas/pandas/core/algorithms.py in isin(comps, values)
421             comps = comps.astype(object)
422
--> 423     return f(comps, values)
424
425

/home/pietro/nobackup/repo/pandas/pandas/core/algorithms.py in <lambda>(x, y)
401     f = lambda x, y: htable.ismember_object(x, values)
402     if (_np_version_under1p8 and compat.PY3) or len(comps) > 1000000:
--> 403         f = lambda x, y: np.in1d(x, y)
404     elif is_integer_dtype(comps):
405         try:

/usr/lib/python3/dist-packages/numpy/lib/arraysetops.py in in1d(ar1, ar2, assume_unique, invert)
399     if not assume_unique:
400         ar1, rev_idx = np.unique(ar1, return_inverse=True)
--> 401         ar2 = np.unique(ar2)
402
403     ar = np.concatenate((ar1, ar2))

/usr/lib/python3/dist-packages/numpy/lib/arraysetops.py in unique(ar, return_index, return_inverse, return_counts)
212         aux = ar[perm]
213     else:
--> 214         ar.sort()
215         aux = ar
216     flag = np.concatenate(([True], aux[1:] != aux[:-1]))

TypeError: unorderable types: str() > int()

# Fixed code
def isin(comps, values):
    """
    Compute the isin boolean array

    Parameters
    ----------
    comps: array-like
    values: array-like

    Returns
    -------
    boolean array same length as comps
    """

    if not is_list_like(comps):
        raise TypeError(
            "only list-like objects are allowed to be passed"
            " to isin(), you passed a "
            "[{0}]".format(type(comps).__name__)
        )
    if not is_list_like(values):
        raise TypeError(
            "only list-like objects are allowed to be passed"
            " to isin(), you passed a "
            "[{0}]".format(type(values).__name__)
        )

    if not isinstance(values, (ABCIndex, ABCSeries, np.ndarray)):
        values = lib.list_to_object_array(list(values))

    comps, dtype, _ = _ensure_data(comps)
    values, _, _ = _ensure_data(values, dtype=dtype)

    # GH11232
    # work-around for numpy < 1.8 and comparisions on py3
    # faster for larger cases to use np.in1d
    f = lambda x, y: htable.ismember_object(x, values)
    # GH16012
    # Ensure np.in1d doesn't get object types or it *may* throw an exception
    if (
        (_np_version_under1p8 and compat.PY3)
        or len(comps) > 1000000
        and not is_object_dtype(comps)
    ):
        f = lambda x, y: np.in1d(x, y)
    elif is_integer_dtype(comps):
        try:
            values = values.astype("int64", copy=False)
            comps = comps.astype("int64", copy=False)
            f = lambda x, y: htable.ismember_int64(x, y)
        except (TypeError, ValueError):
            values = values.astype(object)
            comps = comps.astype(object)

    elif is_float_dtype(comps):
        try:
            values = values.astype("float64", copy=False)
            comps = comps.astype("float64", copy=False)
            checknull = isnull(values).any()
            f = lambda x, y: htable.ismember_float64(x, y, checknull)
        except (TypeError, ValueError):
            values = values.astype(object)
            comps = comps.astype(object)

    return f(comps, values)