cchecksum 0.0.7__tar.gz → 0.0.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cchecksum might be problematic. Click here for more details.

Files changed (44) hide show
  1. {cchecksum-0.0.7 → cchecksum-0.0.9}/.github/workflows/deploy-docs.yaml +6 -0
  2. {cchecksum-0.0.7 → cchecksum-0.0.9}/.github/workflows/release.yaml +1 -1
  3. {cchecksum-0.0.7/cchecksum.egg-info → cchecksum-0.0.9}/PKG-INFO +3 -2
  4. {cchecksum-0.0.7 → cchecksum-0.0.9}/cchecksum/_checksum.c +83 -114
  5. cchecksum-0.0.9/cchecksum/_checksum.pyi +3 -0
  6. {cchecksum-0.0.7 → cchecksum-0.0.9}/cchecksum/_checksum.pyx +7 -8
  7. {cchecksum-0.0.7 → cchecksum-0.0.9}/cchecksum/checksum.py +27 -38
  8. cchecksum-0.0.9/cchecksum/checksum.pyi +31 -0
  9. {cchecksum-0.0.7 → cchecksum-0.0.9/cchecksum.egg-info}/PKG-INFO +3 -2
  10. {cchecksum-0.0.7 → cchecksum-0.0.9}/cchecksum.egg-info/SOURCES.txt +2 -1
  11. cchecksum-0.0.7/cchecksum/_cchecksum.pyi +0 -3
  12. {cchecksum-0.0.7 → cchecksum-0.0.9}/.github/workflows/black.yaml +0 -0
  13. {cchecksum-0.0.7 → cchecksum-0.0.9}/.github/workflows/pytest.yaml +0 -0
  14. {cchecksum-0.0.7 → cchecksum-0.0.9}/.gitignore +0 -0
  15. {cchecksum-0.0.7 → cchecksum-0.0.9}/LICENSE +0 -0
  16. {cchecksum-0.0.7 → cchecksum-0.0.9}/Makefile +0 -0
  17. {cchecksum-0.0.7 → cchecksum-0.0.9}/README.md +0 -0
  18. {cchecksum-0.0.7 → cchecksum-0.0.9}/cchecksum/__init__.py +0 -0
  19. {cchecksum-0.0.7 → cchecksum-0.0.9}/cchecksum/py.typed +0 -0
  20. {cchecksum-0.0.7 → cchecksum-0.0.9}/cchecksum.egg-info/dependency_links.txt +0 -0
  21. {cchecksum-0.0.7 → cchecksum-0.0.9}/cchecksum.egg-info/not-zip-safe +0 -0
  22. {cchecksum-0.0.7 → cchecksum-0.0.9}/cchecksum.egg-info/requires.txt +0 -0
  23. {cchecksum-0.0.7 → cchecksum-0.0.9}/cchecksum.egg-info/top_level.txt +0 -0
  24. {cchecksum-0.0.7 → cchecksum-0.0.9}/docs/Makefile +0 -0
  25. {cchecksum-0.0.7 → cchecksum-0.0.9}/docs/_build/html/_static/alabaster.css +0 -0
  26. {cchecksum-0.0.7 → cchecksum-0.0.9}/docs/_build/html/_static/basic.css +0 -0
  27. {cchecksum-0.0.7 → cchecksum-0.0.9}/docs/_build/html/_static/custom.css +0 -0
  28. {cchecksum-0.0.7 → cchecksum-0.0.9}/docs/_build/html/_static/doctools.js +0 -0
  29. {cchecksum-0.0.7 → cchecksum-0.0.9}/docs/_build/html/_static/documentation_options.js +0 -0
  30. {cchecksum-0.0.7 → cchecksum-0.0.9}/docs/_build/html/_static/file.png +0 -0
  31. {cchecksum-0.0.7 → cchecksum-0.0.9}/docs/_build/html/_static/language_data.js +0 -0
  32. {cchecksum-0.0.7 → cchecksum-0.0.9}/docs/_build/html/_static/minus.png +0 -0
  33. {cchecksum-0.0.7 → cchecksum-0.0.9}/docs/_build/html/_static/plus.png +0 -0
  34. {cchecksum-0.0.7 → cchecksum-0.0.9}/docs/_build/html/_static/pygments.css +0 -0
  35. {cchecksum-0.0.7 → cchecksum-0.0.9}/docs/_build/html/_static/searchtools.js +0 -0
  36. {cchecksum-0.0.7 → cchecksum-0.0.9}/docs/_build/html/_static/sphinx_highlight.js +0 -0
  37. {cchecksum-0.0.7 → cchecksum-0.0.9}/docs/conf.py +0 -0
  38. {cchecksum-0.0.7 → cchecksum-0.0.9}/docs/index.rst +0 -0
  39. {cchecksum-0.0.7 → cchecksum-0.0.9}/docs/make.bat +0 -0
  40. {cchecksum-0.0.7 → cchecksum-0.0.9}/pyproject.toml +0 -0
  41. {cchecksum-0.0.7 → cchecksum-0.0.9}/requirements.txt +0 -0
  42. {cchecksum-0.0.7 → cchecksum-0.0.9}/setup.cfg +0 -0
  43. {cchecksum-0.0.7 → cchecksum-0.0.9}/setup.py +0 -0
  44. {cchecksum-0.0.7 → cchecksum-0.0.9}/test_checksum.py +0 -0
@@ -5,15 +5,21 @@ on:
5
5
  branches:
6
6
  - master
7
7
 
8
+
8
9
  # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
9
10
  permissions:
10
11
  contents: write
11
12
  id-token: write
12
13
  pages: write
14
+
13
15
 
14
16
  jobs:
15
17
  build-and-deploy:
16
18
  runs-on: ubuntu-latest
19
+
20
+ environment:
21
+ name: github-pages
22
+
17
23
  steps:
18
24
  - name: Check out code
19
25
  uses: actions/checkout@v2
@@ -8,7 +8,7 @@ on:
8
8
 
9
9
  jobs:
10
10
  deploy:
11
- runs-on: ubuntu-20.04
11
+ runs-on: ubuntu-latest
12
12
 
13
13
  steps:
14
14
  - uses: actions/checkout@v2
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: cchecksum
3
- Version: 0.0.7
3
+ Version: 0.0.9
4
4
  Summary: A ~2x faster drop-in replacement for eth_utils.to_checksum_address. Raises the exact same Exceptions. Implemented in C.
5
5
  Home-page: https://github.com/BobTheBuidler/cchecksum
6
6
  Author: BobTheBuidler
@@ -15,6 +15,7 @@ Dynamic: author
15
15
  Dynamic: author-email
16
16
  Dynamic: home-page
17
17
  Dynamic: license
18
+ Dynamic: license-file
18
19
  Dynamic: requires-dist
19
20
  Dynamic: requires-python
20
21
  Dynamic: summary
@@ -2903,7 +2903,7 @@ static int __Pyx_ValidateAndInit_memviewslice(
2903
2903
  PyObject *original_obj);
2904
2904
 
2905
2905
  /* ObjectToMemviewSlice.proto */
2906
- static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_char(PyObject *, int writable_flag);
2906
+ static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_char__const__(PyObject *, int writable_flag);
2907
2907
 
2908
2908
  /* MemviewSliceCopyTemplate.proto */
2909
2909
  static __Pyx_memviewslice
@@ -3034,7 +3034,7 @@ static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *, int, size
3034
3034
  static void __pyx_memoryview__slice_assign_scalar(char *, Py_ssize_t *, Py_ssize_t *, int, size_t, void *); /*proto*/
3035
3035
  static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *, PyObject *); /*proto*/
3036
3036
  /* #### Code section: typeinfo ### */
3037
- static __Pyx_TypeInfo __Pyx_TypeInfo_unsigned_char = { "unsigned char", NULL, sizeof(unsigned char), { 0 }, 0, __PYX_IS_UNSIGNED(unsigned char) ? 'U' : 'I', __PYX_IS_UNSIGNED(unsigned char), 0 };
3037
+ static __Pyx_TypeInfo __Pyx_TypeInfo_unsigned_char__const__ = { "const unsigned char", NULL, sizeof(unsigned char const ), { 0 }, 0, __PYX_IS_UNSIGNED(unsigned char const ) ? 'U' : 'I', __PYX_IS_UNSIGNED(unsigned char const ), 0 };
3038
3038
  /* #### Code section: before_global_var ### */
3039
3039
  #define __Pyx_MODULE_NAME "cchecksum._checksum"
3040
3040
  extern int __pyx_module_is_main_cchecksum___checksum;
@@ -3137,7 +3137,6 @@ static const char __pyx_k_stringsource[] = "<stringsource>";
3137
3137
  static const char __pyx_k_version_info[] = "version_info";
3138
3138
  static const char __pyx_k_OverflowError[] = "OverflowError";
3139
3139
  static const char __pyx_k_class_getitem[] = "__class_getitem__";
3140
- static const char __pyx_k_hash_bytes_mv[] = "hash_bytes_mv";
3141
3140
  static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
3142
3141
  static const char __pyx_k_AssertionError[] = "AssertionError";
3143
3142
  static const char __pyx_k_View_MemoryView[] = "View.MemoryView";
@@ -3169,7 +3168,7 @@ static const char __pyx_k_Step_may_not_be_zero_axis_d[] = "Step may not be zero
3169
3168
  static const char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cython.array";
3170
3169
  static const char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data.";
3171
3170
  static const char __pyx_k_strided_and_direct_or_indirect[] = "<strided and direct or indirect>";
3172
- static const char __pyx_k_Computes_the_checksummed_versio[] = "\n Computes the checksummed version of an Ethereum address.\n\n This function takes a normalized Ethereum address (without the '0x' prefix) and its corresponding\n hash (also without the '0x' prefix) and returns the checksummed address as per the Ethereum\n Improvement Proposal 55 (EIP-55).\n\n Args:\n norm_address_no_0x (str): The normalized Ethereum address without the '0x' prefix.\n address_hash_hex_no_0x (str): The hash of the address, also without the '0x' prefix.\n\n Returns:\n The checksummed Ethereum address with the '0x' prefix.\n\n Examples:\n >>> cchecksum(\"b47e3cd837ddf8e4c57f05d70ab865de6e193bbb\", \"abcdef1234567890abcdef1234567890abcdef12\")\n '0xB47E3Cd837DdF8E4C57F05D70Ab865De6E193BbB'\n\n >>> cchecksum(\"0000000000000000000000000000000000000000\", \"1234567890abcdef1234567890abcdef12345678\")\n '0x0000000000000000000000000000000000000000'\n\n See Also:\n - :func:`eth_utils.to_checksum_address`: A utility function for converting addresses to their checksummed form.\n ";
3171
+ static const char __pyx_k_Computes_the_checksummed_versio[] = "\n Computes the checksummed version of an Ethereum address.\n\n This function takes a normalized Ethereum address (without the '0x' prefix) and its corresponding\n hash (also without the '0x' prefix) and returns the checksummed address as per the Ethereum\n Improvement Proposal 55 (EIP-55).\n\n Args:\n norm_address_no_0x (str): The normalized Ethereum address without the '0x' prefix.\n address_hash_hex_no_0x (bytes): The hash of the address, also without the '0x' prefix.\n\n Returns:\n The checksummed Ethereum address with the '0x' prefix.\n\n Examples:\n >>> cchecksum(\"b47e3cd837ddf8e4c57f05d70ab865de6e193bbb\", \"abcdef1234567890abcdef1234567890abcdef12\")\n '0xB47E3Cd837DdF8E4C57F05D70Ab865De6E193BbB'\n\n >>> cchecksum(\"0000000000000000000000000000000000000000\", \"1234567890abcdef1234567890abcdef12345678\")\n '0x0000000000000000000000000000000000000000'\n\n See Also:\n - :func:`eth_utils.to_checksum_address`: A utility function for converting addresses to their checksummed form.\n ";
3173
3172
  static const char __pyx_k_All_dimensions_preceding_dimensi[] = "All dimensions preceding dimension %d must be indexed and not sliced";
3174
3173
  static const char __pyx_k_Buffer_view_does_not_expose_stri[] = "Buffer view does not expose strides";
3175
3174
  static const char __pyx_k_Can_only_create_a_buffer_that_is[] = "Can only create a buffer that is contiguous in memory.";
@@ -3227,7 +3226,7 @@ static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewsl
3227
3226
  static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
3228
3227
  static PyObject *__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
3229
3228
  static PyObject *__pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
3230
- static PyObject *__pyx_pf_9cchecksum_9_checksum_cchecksum(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_norm_address_no_0x, PyObject *__pyx_v_address_hash_hex_no_0x); /* proto */
3229
+ static PyObject *__pyx_pf_9cchecksum_9_checksum_cchecksum(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_norm_address_no_0x, __Pyx_memviewslice __pyx_v_address_hash_hex_no_0x); /* proto */
3231
3230
  static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
3232
3231
  static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
3233
3232
  static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
@@ -3345,7 +3344,6 @@ typedef struct {
3345
3344
  PyObject *__pyx_n_s_getstate;
3346
3345
  PyObject *__pyx_kp_u_got;
3347
3346
  PyObject *__pyx_kp_u_got_differing_extents_in_dimensi;
3348
- PyObject *__pyx_n_s_hash_bytes_mv;
3349
3347
  PyObject *__pyx_n_s_i;
3350
3348
  PyObject *__pyx_n_s_id;
3351
3349
  PyObject *__pyx_n_s_import;
@@ -3553,7 +3551,6 @@ static int __pyx_m_clear(PyObject *m) {
3553
3551
  Py_CLEAR(clear_module_state->__pyx_n_s_getstate);
3554
3552
  Py_CLEAR(clear_module_state->__pyx_kp_u_got);
3555
3553
  Py_CLEAR(clear_module_state->__pyx_kp_u_got_differing_extents_in_dimensi);
3556
- Py_CLEAR(clear_module_state->__pyx_n_s_hash_bytes_mv);
3557
3554
  Py_CLEAR(clear_module_state->__pyx_n_s_i);
3558
3555
  Py_CLEAR(clear_module_state->__pyx_n_s_id);
3559
3556
  Py_CLEAR(clear_module_state->__pyx_n_s_import);
@@ -3739,7 +3736,6 @@ static int __pyx_m_traverse(PyObject *m, visitproc visit, void *arg) {
3739
3736
  Py_VISIT(traverse_module_state->__pyx_n_s_getstate);
3740
3737
  Py_VISIT(traverse_module_state->__pyx_kp_u_got);
3741
3738
  Py_VISIT(traverse_module_state->__pyx_kp_u_got_differing_extents_in_dimensi);
3742
- Py_VISIT(traverse_module_state->__pyx_n_s_hash_bytes_mv);
3743
3739
  Py_VISIT(traverse_module_state->__pyx_n_s_i);
3744
3740
  Py_VISIT(traverse_module_state->__pyx_n_s_id);
3745
3741
  Py_VISIT(traverse_module_state->__pyx_n_s_import);
@@ -3935,7 +3931,6 @@ static int __pyx_m_traverse(PyObject *m, visitproc visit, void *arg) {
3935
3931
  #define __pyx_n_s_getstate __pyx_mstate_global->__pyx_n_s_getstate
3936
3932
  #define __pyx_kp_u_got __pyx_mstate_global->__pyx_kp_u_got
3937
3933
  #define __pyx_kp_u_got_differing_extents_in_dimensi __pyx_mstate_global->__pyx_kp_u_got_differing_extents_in_dimensi
3938
- #define __pyx_n_s_hash_bytes_mv __pyx_mstate_global->__pyx_n_s_hash_bytes_mv
3939
3934
  #define __pyx_n_s_i __pyx_mstate_global->__pyx_n_s_i
3940
3935
  #define __pyx_n_s_id __pyx_mstate_global->__pyx_n_s_id
3941
3936
  #define __pyx_n_s_import __pyx_mstate_global->__pyx_n_s_import
@@ -18007,7 +18002,7 @@ static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *__
18007
18002
  /* "cchecksum/_checksum.pyx":3
18008
18003
  * # cython: boundscheck=False
18009
18004
  *
18010
- * def cchecksum(str norm_address_no_0x, str address_hash_hex_no_0x) -> str: # <<<<<<<<<<<<<<
18005
+ * def cchecksum(str norm_address_no_0x, const unsigned char[::1] address_hash_hex_no_0x) -> str: # <<<<<<<<<<<<<<
18011
18006
  * """
18012
18007
  * Computes the checksummed version of an Ethereum address.
18013
18008
  */
@@ -18020,7 +18015,7 @@ PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
18020
18015
  PyObject *__pyx_args, PyObject *__pyx_kwds
18021
18016
  #endif
18022
18017
  ); /*proto*/
18023
- PyDoc_STRVAR(__pyx_doc_9cchecksum_9_checksum_cchecksum, "cchecksum(unicode norm_address_no_0x, unicode address_hash_hex_no_0x) -> str\n\n Computes the checksummed version of an Ethereum address.\n\n This function takes a normalized Ethereum address (without the '0x' prefix) and its corresponding\n hash (also without the '0x' prefix) and returns the checksummed address as per the Ethereum\n Improvement Proposal 55 (EIP-55).\n\n Args:\n norm_address_no_0x (str): The normalized Ethereum address without the '0x' prefix.\n address_hash_hex_no_0x (str): The hash of the address, also without the '0x' prefix.\n\n Returns:\n The checksummed Ethereum address with the '0x' prefix.\n\n Examples:\n >>> cchecksum(\"b47e3cd837ddf8e4c57f05d70ab865de6e193bbb\", \"abcdef1234567890abcdef1234567890abcdef12\")\n '0xB47E3Cd837DdF8E4C57F05D70Ab865De6E193BbB'\n\n >>> cchecksum(\"0000000000000000000000000000000000000000\", \"1234567890abcdef1234567890abcdef12345678\")\n '0x0000000000000000000000000000000000000000'\n\n See Also:\n - :func:`eth_utils.to_checksum_address`: A utility function for converting addresses to their checksummed form.\n ");
18018
+ PyDoc_STRVAR(__pyx_doc_9cchecksum_9_checksum_cchecksum, "cchecksum(unicode norm_address_no_0x, const unsigned char[::1] address_hash_hex_no_0x) -> str\n\n Computes the checksummed version of an Ethereum address.\n\n This function takes a normalized Ethereum address (without the '0x' prefix) and its corresponding\n hash (also without the '0x' prefix) and returns the checksummed address as per the Ethereum\n Improvement Proposal 55 (EIP-55).\n\n Args:\n norm_address_no_0x (str): The normalized Ethereum address without the '0x' prefix.\n address_hash_hex_no_0x (bytes): The hash of the address, also without the '0x' prefix.\n\n Returns:\n The checksummed Ethereum address with the '0x' prefix.\n\n Examples:\n >>> cchecksum(\"b47e3cd837ddf8e4c57f05d70ab865de6e193bbb\", \"abcdef1234567890abcdef1234567890abcdef12\")\n '0xB47E3Cd837DdF8E4C57F05D70Ab865De6E193BbB'\n\n >>> cchecksum(\"0000000000000000000000000000000000000000\", \"1234567890abcdef1234567890abcdef12345678\")\n '0x0000000000000000000000000000000000000000'\n\n See Also:\n - :func:`eth_utils.to_checksum_address`: A utility function for converting addresses to their checksummed form.\n ");
18024
18019
  static PyMethodDef __pyx_mdef_9cchecksum_9_checksum_1cchecksum = {"cchecksum", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9cchecksum_9_checksum_1cchecksum, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9cchecksum_9_checksum_cchecksum};
18025
18020
  static PyObject *__pyx_pw_9cchecksum_9_checksum_1cchecksum(PyObject *__pyx_self,
18026
18021
  #if CYTHON_METH_FASTCALL
@@ -18030,7 +18025,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds
18030
18025
  #endif
18031
18026
  ) {
18032
18027
  PyObject *__pyx_v_norm_address_no_0x = 0;
18033
- PyObject *__pyx_v_address_hash_hex_no_0x = 0;
18028
+ __Pyx_memviewslice __pyx_v_address_hash_hex_no_0x = { 0, 0, { 0 }, { 0 }, { 0 } };
18034
18029
  #if !CYTHON_METH_FASTCALL
18035
18030
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
18036
18031
  #endif
@@ -18093,7 +18088,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds
18093
18088
  values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
18094
18089
  }
18095
18090
  __pyx_v_norm_address_no_0x = ((PyObject*)values[0]);
18096
- __pyx_v_address_hash_hex_no_0x = ((PyObject*)values[1]);
18091
+ __pyx_v_address_hash_hex_no_0x = __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_char__const__(values[1], 0); if (unlikely(!__pyx_v_address_hash_hex_no_0x.memview)) __PYX_ERR(0, 3, __pyx_L3_error)
18097
18092
  }
18098
18093
  goto __pyx_L6_skip;
18099
18094
  __pyx_L5_argtuple_error:;
@@ -18107,12 +18102,12 @@ PyObject *__pyx_args, PyObject *__pyx_kwds
18107
18102
  __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
18108
18103
  }
18109
18104
  }
18105
+ __PYX_XCLEAR_MEMVIEW(&__pyx_v_address_hash_hex_no_0x, 1);
18110
18106
  __Pyx_AddTraceback("cchecksum._checksum.cchecksum", __pyx_clineno, __pyx_lineno, __pyx_filename);
18111
18107
  __Pyx_RefNannyFinishContext();
18112
18108
  return NULL;
18113
18109
  __pyx_L4_argument_unpacking_done:;
18114
18110
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_norm_address_no_0x), (&PyUnicode_Type), 1, "norm_address_no_0x", 1))) __PYX_ERR(0, 3, __pyx_L1_error)
18115
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_address_hash_hex_no_0x), (&PyUnicode_Type), 1, "address_hash_hex_no_0x", 1))) __PYX_ERR(0, 3, __pyx_L1_error)
18116
18111
  __pyx_r = __pyx_pf_9cchecksum_9_checksum_cchecksum(__pyx_self, __pyx_v_norm_address_no_0x, __pyx_v_address_hash_hex_no_0x);
18117
18112
 
18118
18113
  /* function exit code */
@@ -18120,6 +18115,7 @@ PyObject *__pyx_args, PyObject *__pyx_kwds
18120
18115
  __pyx_L1_error:;
18121
18116
  __pyx_r = NULL;
18122
18117
  __pyx_L0:;
18118
+ __PYX_XCLEAR_MEMVIEW(&__pyx_v_address_hash_hex_no_0x, 1);
18123
18119
  {
18124
18120
  Py_ssize_t __pyx_temp;
18125
18121
  for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
@@ -18130,9 +18126,8 @@ PyObject *__pyx_args, PyObject *__pyx_kwds
18130
18126
  return __pyx_r;
18131
18127
  }
18132
18128
 
18133
- static PyObject *__pyx_pf_9cchecksum_9_checksum_cchecksum(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_norm_address_no_0x, PyObject *__pyx_v_address_hash_hex_no_0x) {
18129
+ static PyObject *__pyx_pf_9cchecksum_9_checksum_cchecksum(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_norm_address_no_0x, __Pyx_memviewslice __pyx_v_address_hash_hex_no_0x) {
18134
18130
  __Pyx_memviewslice __pyx_v_norm_address_mv = { 0, 0, { 0 }, { 0 }, { 0 } };
18135
- __Pyx_memviewslice __pyx_v_hash_bytes_mv = { 0, 0, { 0 }, { 0 }, { 0 } };
18136
18131
  unsigned char __pyx_v_buffer[42];
18137
18132
  int __pyx_v_i;
18138
18133
  int __pyx_v_address_char;
@@ -18140,8 +18135,8 @@ static PyObject *__pyx_pf_9cchecksum_9_checksum_cchecksum(CYTHON_UNUSED PyObject
18140
18135
  __Pyx_TraceDeclarations
18141
18136
  __Pyx_RefNannyDeclarations
18142
18137
  PyObject *__pyx_t_1 = NULL;
18143
- PyObject *__pyx_t_2 = NULL;
18144
- __Pyx_memviewslice __pyx_t_3 = { 0, 0, { 0 }, { 0 }, { 0 } };
18138
+ __Pyx_memviewslice __pyx_t_2 = { 0, 0, { 0 }, { 0 }, { 0 } };
18139
+ PyObject *__pyx_t_3 = NULL;
18145
18140
  unsigned char __pyx_t_4[42];
18146
18141
  int __pyx_t_5;
18147
18142
  Py_ssize_t __pyx_t_6;
@@ -18157,9 +18152,9 @@ static PyObject *__pyx_pf_9cchecksum_9_checksum_cchecksum(CYTHON_UNUSED PyObject
18157
18152
  /* "cchecksum/_checksum.pyx":30
18158
18153
  *
18159
18154
  * # Declare memoryviews for fixed-length data
18160
- * cdef unsigned char[::1] norm_address_mv = bytearray(norm_address_no_0x.encode('ascii')) # <<<<<<<<<<<<<<
18161
- * cdef unsigned char[::1] hash_bytes_mv = bytearray(address_hash_hex_no_0x.encode('ascii'))
18155
+ * cdef const unsigned char[::1] norm_address_mv = norm_address_no_0x.encode('ascii') # <<<<<<<<<<<<<<
18162
18156
  *
18157
+ * # Create a buffer for our result
18163
18158
  */
18164
18159
  __Pyx_TraceLine(30,0,__PYX_ERR(0, 30, __pyx_L1_error))
18165
18160
  if (unlikely(__pyx_v_norm_address_no_0x == Py_None)) {
@@ -18168,120 +18163,96 @@ static PyObject *__pyx_pf_9cchecksum_9_checksum_cchecksum(CYTHON_UNUSED PyObject
18168
18163
  }
18169
18164
  __pyx_t_1 = PyUnicode_AsASCIIString(__pyx_v_norm_address_no_0x); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error)
18170
18165
  __Pyx_GOTREF(__pyx_t_1);
18171
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyByteArray_Type)), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 30, __pyx_L1_error)
18172
- __Pyx_GOTREF(__pyx_t_2);
18173
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
18174
- __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 30, __pyx_L1_error)
18175
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
18176
- __pyx_v_norm_address_mv = __pyx_t_3;
18177
- __pyx_t_3.memview = NULL;
18178
- __pyx_t_3.data = NULL;
18179
-
18180
- /* "cchecksum/_checksum.pyx":31
18181
- * # Declare memoryviews for fixed-length data
18182
- * cdef unsigned char[::1] norm_address_mv = bytearray(norm_address_no_0x.encode('ascii'))
18183
- * cdef unsigned char[::1] hash_bytes_mv = bytearray(address_hash_hex_no_0x.encode('ascii')) # <<<<<<<<<<<<<<
18184
- *
18185
- * # Create a buffer for our result
18186
- */
18187
- __Pyx_TraceLine(31,0,__PYX_ERR(0, 31, __pyx_L1_error))
18188
- if (unlikely(__pyx_v_address_hash_hex_no_0x == Py_None)) {
18189
- PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode");
18190
- __PYX_ERR(0, 31, __pyx_L1_error)
18191
- }
18192
- __pyx_t_2 = PyUnicode_AsASCIIString(__pyx_v_address_hash_hex_no_0x); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error)
18193
- __Pyx_GOTREF(__pyx_t_2);
18194
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyByteArray_Type)), __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error)
18195
- __Pyx_GOTREF(__pyx_t_1);
18196
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
18197
- __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_char(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_3.memview)) __PYX_ERR(0, 31, __pyx_L1_error)
18166
+ __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_char__const__(__pyx_t_1, 0); if (unlikely(!__pyx_t_2.memview)) __PYX_ERR(0, 30, __pyx_L1_error)
18198
18167
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
18199
- __pyx_v_hash_bytes_mv = __pyx_t_3;
18200
- __pyx_t_3.memview = NULL;
18201
- __pyx_t_3.data = NULL;
18168
+ __pyx_v_norm_address_mv = __pyx_t_2;
18169
+ __pyx_t_2.memview = NULL;
18170
+ __pyx_t_2.data = NULL;
18202
18171
 
18203
- /* "cchecksum/_checksum.pyx":35
18172
+ /* "cchecksum/_checksum.pyx":34
18204
18173
  * # Create a buffer for our result
18205
18174
  * # 2 for "0x" prefix and 40 for the address itself
18206
18175
  * cdef unsigned char[42] buffer = b'0x' + bytearray(40) # <<<<<<<<<<<<<<
18207
18176
  *
18208
18177
  * # Handle character casing based on the hash value
18209
18178
  */
18210
- __Pyx_TraceLine(35,0,__PYX_ERR(0, 35, __pyx_L1_error))
18211
- __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyByteArray_Type)), __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error)
18179
+ __Pyx_TraceLine(34,0,__PYX_ERR(0, 34, __pyx_L1_error))
18180
+ __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyByteArray_Type)), __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error)
18212
18181
  __Pyx_GOTREF(__pyx_t_1);
18213
- __pyx_t_2 = PyNumber_Add(__pyx_kp_b_0x, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error)
18214
- __Pyx_GOTREF(__pyx_t_2);
18182
+ __pyx_t_3 = PyNumber_Add(__pyx_kp_b_0x, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 34, __pyx_L1_error)
18183
+ __Pyx_GOTREF(__pyx_t_3);
18215
18184
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
18216
- if (unlikely((__Pyx_carray_from_py_unsigned_char(__pyx_t_2, __pyx_t_4, 42) < 0))) __PYX_ERR(0, 35, __pyx_L1_error)
18185
+ if (unlikely((__Pyx_carray_from_py_unsigned_char(__pyx_t_3, __pyx_t_4, 42) < 0))) __PYX_ERR(0, 34, __pyx_L1_error)
18217
18186
  memcpy(&(__pyx_v_buffer[0]), __pyx_t_4, sizeof(__pyx_v_buffer[0]) * (42));
18218
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
18187
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
18219
18188
 
18220
- /* "cchecksum/_checksum.pyx":41
18189
+ /* "cchecksum/_checksum.pyx":40
18221
18190
  * cdef int address_char
18222
18191
  *
18223
18192
  * for i in range(40): # <<<<<<<<<<<<<<
18224
- * address_char = norm_address_mv[i]
18225
18193
  *
18194
+ * if address_hash_hex_no_0x[i] < 56:
18226
18195
  */
18227
- __Pyx_TraceLine(41,0,__PYX_ERR(0, 41, __pyx_L1_error))
18196
+ __Pyx_TraceLine(40,0,__PYX_ERR(0, 40, __pyx_L1_error))
18228
18197
  for (__pyx_t_5 = 0; __pyx_t_5 < 40; __pyx_t_5+=1) {
18229
18198
  __pyx_v_i = __pyx_t_5;
18230
18199
 
18231
18200
  /* "cchecksum/_checksum.pyx":42
18232
- *
18233
18201
  * for i in range(40):
18234
- * address_char = norm_address_mv[i] # <<<<<<<<<<<<<<
18235
- *
18236
- * if hash_bytes_mv[i] < 56:
18237
- */
18238
- __Pyx_TraceLine(42,0,__PYX_ERR(0, 42, __pyx_L1_error))
18239
- __pyx_t_6 = __pyx_v_i;
18240
- if (__pyx_t_6 < 0) __pyx_t_6 += __pyx_v_norm_address_mv.shape[0];
18241
- __pyx_v_address_char = (*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_norm_address_mv.data) + __pyx_t_6)) )));
18242
-
18243
- /* "cchecksum/_checksum.pyx":44
18244
- * address_char = norm_address_mv[i]
18245
18202
  *
18246
- * if hash_bytes_mv[i] < 56: # <<<<<<<<<<<<<<
18203
+ * if address_hash_hex_no_0x[i] < 56: # <<<<<<<<<<<<<<
18247
18204
  * # '0' to '7' have ASCII values 48 to 55
18248
- * buffer[i + 2] = address_char
18205
+ * buffer[i + 2] = norm_address_mv[i]
18249
18206
  */
18250
- __Pyx_TraceLine(44,0,__PYX_ERR(0, 44, __pyx_L1_error))
18207
+ __Pyx_TraceLine(42,0,__PYX_ERR(0, 42, __pyx_L1_error))
18251
18208
  __pyx_t_6 = __pyx_v_i;
18252
- if (__pyx_t_6 < 0) __pyx_t_6 += __pyx_v_hash_bytes_mv.shape[0];
18253
- __pyx_t_7 = ((*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_hash_bytes_mv.data) + __pyx_t_6)) ))) < 56);
18209
+ if (__pyx_t_6 < 0) __pyx_t_6 += __pyx_v_address_hash_hex_no_0x.shape[0];
18210
+ __pyx_t_7 = ((*((unsigned char const *) ( /* dim=0 */ ((char *) (((unsigned char const *) __pyx_v_address_hash_hex_no_0x.data) + __pyx_t_6)) ))) < 56);
18254
18211
  if (__pyx_t_7) {
18255
18212
 
18256
- /* "cchecksum/_checksum.pyx":46
18257
- * if hash_bytes_mv[i] < 56:
18213
+ /* "cchecksum/_checksum.pyx":44
18214
+ * if address_hash_hex_no_0x[i] < 56:
18258
18215
  * # '0' to '7' have ASCII values 48 to 55
18259
- * buffer[i + 2] = address_char # <<<<<<<<<<<<<<
18216
+ * buffer[i + 2] = norm_address_mv[i] # <<<<<<<<<<<<<<
18260
18217
  *
18261
18218
  * else:
18262
18219
  */
18263
- __Pyx_TraceLine(46,0,__PYX_ERR(0, 46, __pyx_L1_error))
18264
- (__pyx_v_buffer[(__pyx_v_i + 2)]) = __pyx_v_address_char;
18220
+ __Pyx_TraceLine(44,0,__PYX_ERR(0, 44, __pyx_L1_error))
18221
+ __pyx_t_6 = __pyx_v_i;
18222
+ if (__pyx_t_6 < 0) __pyx_t_6 += __pyx_v_norm_address_mv.shape[0];
18223
+ (__pyx_v_buffer[(__pyx_v_i + 2)]) = (*((unsigned char const *) ( /* dim=0 */ ((char *) (((unsigned char const *) __pyx_v_norm_address_mv.data) + __pyx_t_6)) )));
18265
18224
 
18266
- /* "cchecksum/_checksum.pyx":44
18267
- * address_char = norm_address_mv[i]
18225
+ /* "cchecksum/_checksum.pyx":42
18226
+ * for i in range(40):
18268
18227
  *
18269
- * if hash_bytes_mv[i] < 56: # <<<<<<<<<<<<<<
18228
+ * if address_hash_hex_no_0x[i] < 56: # <<<<<<<<<<<<<<
18270
18229
  * # '0' to '7' have ASCII values 48 to 55
18271
- * buffer[i + 2] = address_char
18230
+ * buffer[i + 2] = norm_address_mv[i]
18272
18231
  */
18273
18232
  goto __pyx_L5;
18274
18233
  }
18275
18234
 
18276
- /* "cchecksum/_checksum.pyx":52
18235
+ /* "cchecksum/_checksum.pyx":47
18236
+ *
18237
+ * else:
18238
+ * address_char = norm_address_mv[i] # <<<<<<<<<<<<<<
18239
+ * # This checks if `address_char` falls in the ASCII range for lowercase hexadecimal
18240
+ * # characters ('a' to 'f'), which correspond to ASCII values 97 to 102. If it does,
18241
+ */
18242
+ __Pyx_TraceLine(47,0,__PYX_ERR(0, 47, __pyx_L1_error))
18243
+ /*else*/ {
18244
+ __pyx_t_6 = __pyx_v_i;
18245
+ if (__pyx_t_6 < 0) __pyx_t_6 += __pyx_v_norm_address_mv.shape[0];
18246
+ __pyx_v_address_char = (*((unsigned char const *) ( /* dim=0 */ ((char *) (((unsigned char const *) __pyx_v_norm_address_mv.data) + __pyx_t_6)) )));
18247
+
18248
+ /* "cchecksum/_checksum.pyx":51
18277
18249
  * # characters ('a' to 'f'), which correspond to ASCII values 97 to 102. If it does,
18278
18250
  * # the character is capitalized.
18279
18251
  * buffer[i + 2] = address_char - 32 if 97 <= address_char <= 102 else address_char # <<<<<<<<<<<<<<
18280
18252
  *
18281
18253
  * # NOTE: For some reason on some systems the buffer length is longer than 42 here, even though that should not be possible.
18282
18254
  */
18283
- __Pyx_TraceLine(52,0,__PYX_ERR(0, 52, __pyx_L1_error))
18284
- /*else*/ {
18255
+ __Pyx_TraceLine(51,0,__PYX_ERR(0, 51, __pyx_L1_error))
18285
18256
  __pyx_t_7 = (97 <= __pyx_v_address_char);
18286
18257
  if (__pyx_t_7) {
18287
18258
  __pyx_t_7 = (__pyx_v_address_char <= 0x66);
@@ -18296,29 +18267,29 @@ static PyObject *__pyx_pf_9cchecksum_9_checksum_cchecksum(CYTHON_UNUSED PyObject
18296
18267
  __pyx_L5:;
18297
18268
  }
18298
18269
 
18299
- /* "cchecksum/_checksum.pyx":56
18270
+ /* "cchecksum/_checksum.pyx":55
18300
18271
  * # NOTE: For some reason on some systems the buffer length is longer than 42 here, even though that should not be possible.
18301
18272
  * # Lucky for us, the first 42 characters are always correct. One day maybe I'll debug this.
18302
18273
  * return bytes(buffer[:42]).decode('ascii') # <<<<<<<<<<<<<<
18303
18274
  */
18304
- __Pyx_TraceLine(56,0,__PYX_ERR(0, 56, __pyx_L1_error))
18275
+ __Pyx_TraceLine(55,0,__PYX_ERR(0, 55, __pyx_L1_error))
18305
18276
  __Pyx_XDECREF(__pyx_r);
18306
- __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_buffer) + 0, 42 - 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error)
18307
- __Pyx_GOTREF(__pyx_t_2);
18308
- __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyBytes_Type)), __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error)
18277
+ __pyx_t_3 = __Pyx_PyBytes_FromStringAndSize(((const char*)__pyx_v_buffer) + 0, 42 - 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 55, __pyx_L1_error)
18278
+ __Pyx_GOTREF(__pyx_t_3);
18279
+ __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyBytes_Type)), __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error)
18309
18280
  __Pyx_GOTREF(__pyx_t_1);
18310
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
18311
- __pyx_t_2 = __Pyx_decode_bytes(__pyx_t_1, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error)
18312
- __Pyx_GOTREF(__pyx_t_2);
18281
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
18282
+ __pyx_t_3 = __Pyx_decode_bytes(__pyx_t_1, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 55, __pyx_L1_error)
18283
+ __Pyx_GOTREF(__pyx_t_3);
18313
18284
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
18314
- __pyx_r = ((PyObject*)__pyx_t_2);
18315
- __pyx_t_2 = 0;
18285
+ __pyx_r = ((PyObject*)__pyx_t_3);
18286
+ __pyx_t_3 = 0;
18316
18287
  goto __pyx_L0;
18317
18288
 
18318
18289
  /* "cchecksum/_checksum.pyx":3
18319
18290
  * # cython: boundscheck=False
18320
18291
  *
18321
- * def cchecksum(str norm_address_no_0x, str address_hash_hex_no_0x) -> str: # <<<<<<<<<<<<<<
18292
+ * def cchecksum(str norm_address_no_0x, const unsigned char[::1] address_hash_hex_no_0x) -> str: # <<<<<<<<<<<<<<
18322
18293
  * """
18323
18294
  * Computes the checksummed version of an Ethereum address.
18324
18295
  */
@@ -18326,13 +18297,12 @@ static PyObject *__pyx_pf_9cchecksum_9_checksum_cchecksum(CYTHON_UNUSED PyObject
18326
18297
  /* function exit code */
18327
18298
  __pyx_L1_error:;
18328
18299
  __Pyx_XDECREF(__pyx_t_1);
18329
- __Pyx_XDECREF(__pyx_t_2);
18330
- __PYX_XCLEAR_MEMVIEW(&__pyx_t_3, 1);
18300
+ __PYX_XCLEAR_MEMVIEW(&__pyx_t_2, 1);
18301
+ __Pyx_XDECREF(__pyx_t_3);
18331
18302
  __Pyx_AddTraceback("cchecksum._checksum.cchecksum", __pyx_clineno, __pyx_lineno, __pyx_filename);
18332
18303
  __pyx_r = NULL;
18333
18304
  __pyx_L0:;
18334
18305
  __PYX_XCLEAR_MEMVIEW(&__pyx_v_norm_address_mv, 1);
18335
- __PYX_XCLEAR_MEMVIEW(&__pyx_v_hash_bytes_mv, 1);
18336
18306
  __Pyx_XGIVEREF(__pyx_r);
18337
18307
  __Pyx_TraceReturn(__pyx_r, 0);
18338
18308
  __Pyx_RefNannyFinishContext();
@@ -19389,7 +19359,6 @@ static int __Pyx_CreateStringTabAndInitStrings(void) {
19389
19359
  {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
19390
19360
  {&__pyx_kp_u_got, __pyx_k_got, sizeof(__pyx_k_got), 0, 1, 0, 0},
19391
19361
  {&__pyx_kp_u_got_differing_extents_in_dimensi, __pyx_k_got_differing_extents_in_dimensi, sizeof(__pyx_k_got_differing_extents_in_dimensi), 0, 1, 0, 0},
19392
- {&__pyx_n_s_hash_bytes_mv, __pyx_k_hash_bytes_mv, sizeof(__pyx_k_hash_bytes_mv), 0, 0, 1, 1},
19393
19362
  {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
19394
19363
  {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
19395
19364
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
@@ -19452,7 +19421,7 @@ static int __Pyx_CreateStringTabAndInitStrings(void) {
19452
19421
  }
19453
19422
  /* #### Code section: cached_builtins ### */
19454
19423
  static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
19455
- __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 41, __pyx_L1_error)
19424
+ __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 40, __pyx_L1_error)
19456
19425
  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 83, __pyx_L1_error)
19457
19426
  __pyx_builtin_OverflowError = __Pyx_GetBuiltinName(__pyx_n_s_OverflowError); if (!__pyx_builtin_OverflowError) __PYX_ERR(1, 83, __pyx_L1_error)
19458
19427
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(1, 86, __pyx_L1_error)
@@ -19509,14 +19478,14 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
19509
19478
  __Pyx_GOTREF(__pyx_tuple__8);
19510
19479
  __Pyx_GIVEREF(__pyx_tuple__8);
19511
19480
 
19512
- /* "cchecksum/_checksum.pyx":35
19481
+ /* "cchecksum/_checksum.pyx":34
19513
19482
  * # Create a buffer for our result
19514
19483
  * # 2 for "0x" prefix and 40 for the address itself
19515
19484
  * cdef unsigned char[42] buffer = b'0x' + bytearray(40) # <<<<<<<<<<<<<<
19516
19485
  *
19517
19486
  * # Handle character casing based on the hash value
19518
19487
  */
19519
- __pyx_tuple__10 = PyTuple_Pack(1, __pyx_int_40); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 35, __pyx_L1_error)
19488
+ __pyx_tuple__10 = PyTuple_Pack(1, __pyx_int_40); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 34, __pyx_L1_error)
19520
19489
  __Pyx_GOTREF(__pyx_tuple__10);
19521
19490
  __Pyx_GIVEREF(__pyx_tuple__10);
19522
19491
 
@@ -19624,14 +19593,14 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
19624
19593
  /* "cchecksum/_checksum.pyx":3
19625
19594
  * # cython: boundscheck=False
19626
19595
  *
19627
- * def cchecksum(str norm_address_no_0x, str address_hash_hex_no_0x) -> str: # <<<<<<<<<<<<<<
19596
+ * def cchecksum(str norm_address_no_0x, const unsigned char[::1] address_hash_hex_no_0x) -> str: # <<<<<<<<<<<<<<
19628
19597
  * """
19629
19598
  * Computes the checksummed version of an Ethereum address.
19630
19599
  */
19631
- __pyx_tuple__22 = PyTuple_Pack(7, __pyx_n_s_norm_address_no_0x, __pyx_n_s_address_hash_hex_no_0x, __pyx_n_s_norm_address_mv, __pyx_n_s_hash_bytes_mv, __pyx_n_s_buffer, __pyx_n_s_i, __pyx_n_s_address_char); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 3, __pyx_L1_error)
19600
+ __pyx_tuple__22 = PyTuple_Pack(6, __pyx_n_s_norm_address_no_0x, __pyx_n_s_address_hash_hex_no_0x, __pyx_n_s_norm_address_mv, __pyx_n_s_buffer, __pyx_n_s_i, __pyx_n_s_address_char); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 3, __pyx_L1_error)
19632
19601
  __Pyx_GOTREF(__pyx_tuple__22);
19633
19602
  __Pyx_GIVEREF(__pyx_tuple__22);
19634
- __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cchecksum__checksum_pyx, __pyx_n_s_cchecksum, 3, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 3, __pyx_L1_error)
19603
+ __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cchecksum__checksum_pyx, __pyx_n_s_cchecksum, 3, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 3, __pyx_L1_error)
19635
19604
  __Pyx_RefNannyFinishContext();
19636
19605
  return 0;
19637
19606
  __pyx_L1_error:;
@@ -20698,7 +20667,7 @@ if (!__Pyx_RefNanny) {
20698
20667
  /* "cchecksum/_checksum.pyx":3
20699
20668
  * # cython: boundscheck=False
20700
20669
  *
20701
- * def cchecksum(str norm_address_no_0x, str address_hash_hex_no_0x) -> str: # <<<<<<<<<<<<<<
20670
+ * def cchecksum(str norm_address_no_0x, const unsigned char[::1] address_hash_hex_no_0x) -> str: # <<<<<<<<<<<<<<
20702
20671
  * """
20703
20672
  * Computes the checksummed version of an Ethereum address.
20704
20673
  */
@@ -20716,7 +20685,7 @@ if (!__Pyx_RefNanny) {
20716
20685
  /* "cchecksum/_checksum.pyx":1
20717
20686
  * # cython: boundscheck=False # <<<<<<<<<<<<<<
20718
20687
  *
20719
- * def cchecksum(str norm_address_no_0x, str address_hash_hex_no_0x) -> str:
20688
+ * def cchecksum(str norm_address_no_0x, const unsigned char[::1] address_hash_hex_no_0x) -> str:
20720
20689
  */
20721
20690
  __Pyx_TraceLine(1,0,__PYX_ERR(0, 1, __pyx_L1_error))
20722
20691
  __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1, __pyx_L1_error)
@@ -26271,7 +26240,7 @@ no_fail:
26271
26240
  }
26272
26241
 
26273
26242
  /* ObjectToMemviewSlice */
26274
- static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_char(PyObject *obj, int writable_flag) {
26243
+ static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_char__const__(PyObject *obj, int writable_flag) {
26275
26244
  __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
26276
26245
  __Pyx_BufFmt_StackElem stack[1];
26277
26246
  int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
@@ -26282,7 +26251,7 @@ no_fail:
26282
26251
  }
26283
26252
  retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
26284
26253
  (PyBUF_C_CONTIGUOUS | PyBUF_FORMAT) | writable_flag, 1,
26285
- &__Pyx_TypeInfo_unsigned_char, stack,
26254
+ &__Pyx_TypeInfo_unsigned_char__const__, stack,
26286
26255
  &result, obj);
26287
26256
  if (unlikely(retcode == -1))
26288
26257
  goto __pyx_fail;
@@ -0,0 +1,3 @@
1
+ from eth_typing import ChecksumAddress
2
+
3
+ def cchecksum(norm_address_no_0x: str, address_hash_hex_no_0x: bytearray) -> ChecksumAddress: ...
@@ -1,6 +1,6 @@
1
1
  # cython: boundscheck=False
2
2
 
3
- def cchecksum(str norm_address_no_0x, str address_hash_hex_no_0x) -> str:
3
+ def cchecksum(str norm_address_no_0x, const unsigned char[::1] address_hash_hex_no_0x) -> str:
4
4
  """
5
5
  Computes the checksummed version of an Ethereum address.
6
6
 
@@ -10,7 +10,7 @@ def cchecksum(str norm_address_no_0x, str address_hash_hex_no_0x) -> str:
10
10
 
11
11
  Args:
12
12
  norm_address_no_0x (str): The normalized Ethereum address without the '0x' prefix.
13
- address_hash_hex_no_0x (str): The hash of the address, also without the '0x' prefix.
13
+ address_hash_hex_no_0x (bytes): The hash of the address, also without the '0x' prefix.
14
14
 
15
15
  Returns:
16
16
  The checksummed Ethereum address with the '0x' prefix.
@@ -27,8 +27,7 @@ def cchecksum(str norm_address_no_0x, str address_hash_hex_no_0x) -> str:
27
27
  """
28
28
 
29
29
  # Declare memoryviews for fixed-length data
30
- cdef unsigned char[::1] norm_address_mv = bytearray(norm_address_no_0x.encode('ascii'))
31
- cdef unsigned char[::1] hash_bytes_mv = bytearray(address_hash_hex_no_0x.encode('ascii'))
30
+ cdef const unsigned char[::1] norm_address_mv = norm_address_no_0x.encode('ascii')
32
31
 
33
32
  # Create a buffer for our result
34
33
  # 2 for "0x" prefix and 40 for the address itself
@@ -39,14 +38,14 @@ def cchecksum(str norm_address_no_0x, str address_hash_hex_no_0x) -> str:
39
38
  cdef int address_char
40
39
 
41
40
  for i in range(40):
42
- address_char = norm_address_mv[i]
43
41
 
44
- if hash_bytes_mv[i] < 56:
42
+ if address_hash_hex_no_0x[i] < 56:
45
43
  # '0' to '7' have ASCII values 48 to 55
46
- buffer[i + 2] = address_char
44
+ buffer[i + 2] = norm_address_mv[i]
47
45
 
48
46
  else:
49
- # This checks if `norm_char` falls in the ASCII range for lowercase hexadecimal
47
+ address_char = norm_address_mv[i]
48
+ # This checks if `address_char` falls in the ASCII range for lowercase hexadecimal
50
49
  # characters ('a' to 'f'), which correspond to ASCII values 97 to 102. If it does,
51
50
  # the character is capitalized.
52
51
  buffer[i + 2] = address_char - 32 if 97 <= address_char <= 102 else address_char
@@ -3,12 +3,24 @@ from typing import Optional, Union
3
3
 
4
4
  from eth_hash.auto import keccak
5
5
  from eth_typing import AnyAddress, ChecksumAddress, HexAddress, HexStr, Primitives
6
- from eth_utils import add_0x_prefix, encode_hex, hexstr_if_str
6
+ from eth_utils import encode_hex, hexstr_if_str
7
7
  from eth_utils.address import _HEX_ADDRESS_REGEXP
8
+ from eth_utils.toolz import compose
8
9
 
9
10
  from cchecksum._checksum import cchecksum
10
11
 
11
12
 
13
+ BytesLike = Union[Primitives, bytearray, memoryview]
14
+
15
+
16
+ # force _hasher_first_run and _preimage_first_run to execute so we can cache the new hasher
17
+ keccak(b"")
18
+
19
+ hash_address = compose(hexlify, bytes, keccak.hasher, str.encode)
20
+
21
+ hex_address_fullmatch = _HEX_ADDRESS_REGEXP.fullmatch
22
+
23
+
12
24
  # this was ripped out of eth_utils and optimized a little bit
13
25
 
14
26
 
@@ -40,9 +52,7 @@ def to_checksum_address(value: Union[AnyAddress, str, bytes]) -> ChecksumAddress
40
52
  - :func:`to_normalized_address` for converting to a normalized address before checksumming.
41
53
  """
42
54
  norm_address_no_0x = to_normalized_address(value)[2:]
43
- address_hash = bytes(keccak(norm_address_no_0x.encode("utf-8")))
44
- address_hash_hex_no_0x = hexlify(address_hash).decode("ascii")
45
- return cchecksum(norm_address_no_0x, address_hash_hex_no_0x)
55
+ return cchecksum(norm_address_no_0x, hash_address(norm_address_no_0x))
46
56
 
47
57
 
48
58
  def to_normalized_address(value: Union[AnyAddress, str, bytes]) -> HexAddress:
@@ -75,10 +85,13 @@ def to_normalized_address(value: Union[AnyAddress, str, bytes]) -> HexAddress:
75
85
  """
76
86
  try:
77
87
  hex_address = hexstr_if_str(to_hex, value).lower()
78
- except AttributeError:
79
- raise TypeError(f"Value must be any string, instead got type {type(value)}")
88
+ except AttributeError as e:
89
+ raise TypeError(
90
+ f"Value must be any string, instead got type {type(value)}"
91
+ ) from e.__cause__
80
92
 
81
- if not is_address(hex_address):
93
+ # if `hex_address` is not a valid address
94
+ if hex_address_fullmatch(hex_address) is None:
82
95
  raise ValueError(
83
96
  f"Unknown format {repr(value)}, attempted to normalize to {repr(hex_address)}"
84
97
  )
@@ -86,33 +99,7 @@ def to_normalized_address(value: Union[AnyAddress, str, bytes]) -> HexAddress:
86
99
  return hex_address # type: ignore [return-value]
87
100
 
88
101
 
89
- def is_address(value: str) -> bool:
90
- """
91
- Check if the given string is a valid address in any known format.
92
-
93
- This function uses a regular expression to determine if the input string
94
- matches the expected pattern for a hexadecimal address.
95
-
96
- Args:
97
- value: The string to be checked.
98
-
99
- Returns:
100
- True if the string is a valid address, False otherwise.
101
-
102
- Examples:
103
- >>> is_address("0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb")
104
- True
105
-
106
- >>> is_address("not-an-address")
107
- False
108
-
109
- See Also:
110
- - :func:`eth_utils.is_address` for the standard implementation.
111
- """
112
- return _HEX_ADDRESS_REGEXP.fullmatch(value) is not None
113
-
114
-
115
- BytesLike = Union[Primitives, bytearray, memoryview]
102
+ encode_memoryview = compose(encode_hex, bytes)
116
103
 
117
104
 
118
105
  def to_hex(
@@ -132,13 +119,15 @@ def to_hex(
132
119
  return encode_hex(address_bytes)
133
120
 
134
121
  if isinstance(address_bytes, memoryview):
135
- return encode_hex(bytes(address_bytes))
122
+ return encode_memoryview(address_bytes)
136
123
 
137
124
  raise TypeError(
138
125
  f"Unsupported type: '{repr(type(address_bytes))}'. Must be one of: bytes or bytearray."
139
126
  )
140
127
 
141
128
 
142
- # force _hasher_first_run and _preimage_first_run to execute so we can cache the new hasher
143
- keccak(b"")
144
- keccak = keccak.hasher
129
+ del hexlify
130
+ del Optional, Union
131
+ del AnyAddress, ChecksumAddress, HexAddress, HexStr, Primitives
132
+ del _HEX_ADDRESS_REGEXP, compose, keccak
133
+ del BytesLike
@@ -0,0 +1,31 @@
1
+ from typing import Union
2
+
3
+ from eth_typing import AnyAddress, ChecksumAddress
4
+
5
+ def to_checksum_address(value: Union[AnyAddress, str, bytes]) -> ChecksumAddress:
6
+ """
7
+ Convert an address to its EIP-55 checksum format.
8
+
9
+ This function takes an address in any supported format and returns it in the
10
+ checksummed format as defined by EIP-55. It uses a custom Cython implementation
11
+ for the checksum conversion to optimize performance.
12
+
13
+ Args:
14
+ value: The address to be converted. It can be in any format supported by
15
+ :func:`eth_utils.to_normalized_address`.
16
+
17
+ Raises:
18
+ ValueError: If the input address is not in a recognized format.
19
+ TypeError: If the input is not a string, bytes, or any address type.
20
+
21
+ Examples:
22
+ >>> to_checksum_address("0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb")
23
+ '0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB'
24
+
25
+ >>> to_checksum_address(b'\xb4~<\xd87\xdd\xf8\xe4\xc5\x7f\x05\xd7\n\xb8e\xden\x19;\xbb')
26
+ '0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB'
27
+
28
+ See Also:
29
+ - :func:`eth_utils.to_checksum_address` for the standard implementation.
30
+ - :func:`to_normalized_address` for converting to a normalized address before checksumming.
31
+ """
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: cchecksum
3
- Version: 0.0.7
3
+ Version: 0.0.9
4
4
  Summary: A ~2x faster drop-in replacement for eth_utils.to_checksum_address. Raises the exact same Exceptions. Implemented in C.
5
5
  Home-page: https://github.com/BobTheBuidler/cchecksum
6
6
  Author: BobTheBuidler
@@ -15,6 +15,7 @@ Dynamic: author
15
15
  Dynamic: author-email
16
16
  Dynamic: home-page
17
17
  Dynamic: license
18
+ Dynamic: license-file
18
19
  Dynamic: requires-dist
19
20
  Dynamic: requires-python
20
21
  Dynamic: summary
@@ -11,10 +11,11 @@ test_checksum.py
11
11
  .github/workflows/pytest.yaml
12
12
  .github/workflows/release.yaml
13
13
  cchecksum/__init__.py
14
- cchecksum/_cchecksum.pyi
15
14
  cchecksum/_checksum.c
15
+ cchecksum/_checksum.pyi
16
16
  cchecksum/_checksum.pyx
17
17
  cchecksum/checksum.py
18
+ cchecksum/checksum.pyi
18
19
  cchecksum/py.typed
19
20
  cchecksum.egg-info/PKG-INFO
20
21
  cchecksum.egg-info/SOURCES.txt
@@ -1,3 +0,0 @@
1
- from eth_typing import ChecksumAddress
2
-
3
- def cchecksum(norm_address_no_0x: str, address_hash_hex_no_0x: str) -> ChecksumAddress: ...
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes