def enum(option, *options):
    """
    Construct a new enum object.

    Parameters
    ----------
    *options : iterable of str
        The names of the fields for the enum.

    Returns
    -------
    enum
        A new enum collection.

    Examples
    --------
    >>> e = enum('a', 'b', 'c')
    >>> e
    <enum: ('a', 'b', 'c')>
    >>> e.a
    0
    >>> e.b
    1
    >>> e.a in e
    True
    >>> tuple(e)
    (0, 1, 2)

    Notes
    -----
    Identity checking is not guaranteed to work with enum members, instead
    equality checks should be used. From CPython's documentation:

    "The current implementation keeps an array of integer objects for all
    integers between -5 and 256, when you create an int in that range you
    actually just get back a reference to the existing object. So it should be
    possible to change the value of 1. I suspect the behaviour of Python in
    this case is undefined. :-)"
    """
    options = (option,) + options
    rangeob = range(len(options))

    try:
        inttype = _inttypes[int(np.log2(len(options) - 1)) // 8]
    except IndexError:
        raise OverflowError(
            'Cannot store enums with more than sys.maxsize elements, got %d' %
            len(options),
        )

    class _enum(Structure):
        _fields_ = [(o, inttype) for o in options]

        def __iter__(self):
            return iter(rangeob)

        def __contains__(self, value):
            return 0 <= value < len(options)

        def __repr__(self):
            return '<enum: %s>' % (
                ('%d fields' % len(options))
                if len(options) > 10 else
                repr(options)
            )

    return _enum(*rangeob)
dataset/ETHPy150Open quantopian/zipline/zipline/utils/enum.py/enum/original