Download deepseek/lib/python3.10/site-packages/numba/cpython/enumimpl.py from ZTWHHH/envs_1: direct link, hf CLI and curl.
- Browser
- Download file 2.91 kB
-
https://huggingface.co/datasets/ZTWHHH/envs_1/resolve/main/deepseek/lib/python3.10/site-packages/numba/cpython/enumimpl.py
- Command line
-
hf download hf://datasets/ZTWHHH/envs_1/deepseek/lib/python3.10/site-packages/numba/cpython/enumimpl.py
-
curl -L -o enumimpl.py https://huggingface.co/datasets/ZTWHHH/envs_1/resolve/main/deepseek/lib/python3.10/site-packages/numba/cpython/enumimpl.py
2.91 kB
| """ | |
| Implementation of enums. | |
| """ | |
| import operator | |
| from numba.core.imputils import (lower_builtin, lower_getattr, | |
| lower_getattr_generic, lower_cast, | |
| lower_constant, impl_ret_untracked) | |
| from numba.core import types | |
| from numba.core.extending import overload_method | |
| def enum_eq(context, builder, sig, args): | |
| tu, tv = sig.args | |
| u, v = args | |
| res = context.generic_compare(builder, operator.eq, | |
| (tu.dtype, tv.dtype), (u, v)) | |
| return impl_ret_untracked(context, builder, sig.return_type, res) | |
| def enum_is(context, builder, sig, args): | |
| tu, tv = sig.args | |
| u, v = args | |
| if tu == tv: | |
| res = context.generic_compare(builder, operator.eq, | |
| (tu.dtype, tv.dtype), (u, v)) | |
| else: | |
| res = context.get_constant(sig.return_type, False) | |
| return impl_ret_untracked(context, builder, sig.return_type, res) | |
| def enum_ne(context, builder, sig, args): | |
| tu, tv = sig.args | |
| u, v = args | |
| res = context.generic_compare(builder, operator.ne, | |
| (tu.dtype, tv.dtype), (u, v)) | |
| return impl_ret_untracked(context, builder, sig.return_type, res) | |
| def enum_value(context, builder, ty, val): | |
| return val | |
| def int_enum_to_int(context, builder, fromty, toty, val): | |
| """ | |
| Convert an IntEnum member to its raw integer value. | |
| """ | |
| return context.cast(builder, val, fromty.dtype, toty) | |
| def enum_constant(context, builder, ty, pyval): | |
| """ | |
| Return a LLVM constant representing enum member *pyval*. | |
| """ | |
| return context.get_constant_generic(builder, ty.dtype, pyval.value) | |
| def enum_class_getattr(context, builder, ty, val, attr): | |
| """ | |
| Return an enum member by attribute name. | |
| """ | |
| member = getattr(ty.instance_class, attr) | |
| return context.get_constant_generic(builder, ty.dtype, member.value) | |
| def enum_class_getitem(context, builder, sig, args): | |
| """ | |
| Return an enum member by index name. | |
| """ | |
| enum_cls_typ, idx = sig.args | |
| member = enum_cls_typ.instance_class[idx.literal_value] | |
| return context.get_constant_generic(builder, enum_cls_typ.dtype, | |
| member.value) | |
| def intenum_hash(val): | |
| # uses the hash of the value, for IntEnums this will be int.__hash__ | |
| def hash_impl(val): | |
| return hash(val.value) | |
| return hash_impl | |