MCPcopy Index your code
hub / github.com/cryptape/rust-numext

github.com/cryptape/rust-numext @v0.1.6

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.6 ↗ · + Follow
317 symbols 714 edges 107 files 13 documented · 4%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Rust-NumExt

License Travis CI AppVeyor

Extend the rust built-in numeric types.

Crates

Name Crate Documentation Description
[numext-fixed-uint] Uint Badge Uint Doc Fixed-size uint structures.
[numext-fixed-hash] Hash Badge Hash Doc Fixed-size hash structures.

Requirements

  • rustc 1.45.0+.

Require Stabilizing function-like procedural macros in expressions, patterns, and statements.

Benchmark

Howto

cargo bench

Results on Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz

  • + means better; - means worse.
  • nfuint and nfhash is short for [numext-fixed-uint] and [numext-fixed-hash].
  • etypes is short for ethereum-types.

Serialization / Deserialization Benchmark:

+serde/ser/nfhash/h256   time:   [56.812 ns 56.834 ns 56.855 ns]
-serde/ser/etypes/h256   time:   [101.41 ns 102.24 ns 103.30 ns]
+serde/de/nfhash/h256    time:   [96.613 ns 96.643 ns 96.672 ns]
-serde/de/etypes/h256    time:   [160.63 ns 160.73 ns 160.89 ns]

-serde/ser/nfuint/u256   time:   [114.36 ns 114.66 ns 115.14 ns]
+serde/ser/etypes/u256   time:   [102.49 ns 102.55 ns 102.59 ns]
+serde/de/nfuint/u256    time:   [117.83 ns 117.85 ns 117.88 ns]
-serde/de/etypes/u256    time:   [175.12 ns 175.20 ns 175.29 ns]

Calculation Benchmark:

+gcd/nfuint              time:   [2.7441 us 2.7444 us 2.7447 us]
-gcd/num_bigint          time:   [6.9668 us 6.9683 us 6.9697 us]

+add/nfuint              time:   [2.7960 ns 2.8020 ns 2.8067 ns]
-add/etypes              time:   [4.9120 ns 4.9152 ns 4.9183 ns]
+sub/nfuint              time:   [2.7734 ns 2.7812 ns 2.7884 ns]
-sub/etypes              time:   [4.9641 ns 4.9679 ns 4.9715 ns]
+mul/nfuint              time:   [13.786 ns 13.788 ns 13.790 ns]
-mul/etypes              time:   [14.946 ns 14.950 ns 14.956 ns]
+div/nfuint              time:   [25.820 ns 25.826 ns 25.832 ns]
-div/etypes              time:   [77.297 ns 77.300 ns 77.304 ns]
+rem/nfuint              time:   [26.454 ns 26.455 ns 26.458 ns]
-rem/etypes              time:   [72.860 ns 72.902 ns 72.958 ns]
+bitand/nfuint           time:   [3.6945 ns 3.6946 ns 3.6947 ns]
-bitand/etypes           time:   [5.3184 ns 5.3224 ns 5.3267 ns]
+bitor/nfuint            time:   [3.6945 ns 3.6947 ns 3.6948 ns]
-bitor/etypes            time:   [5.3298 ns 5.3323 ns 5.3347 ns]
+bitxor/nfuint           time:   [3.6944 ns 3.6946 ns 3.6947 ns]
-bitxor/etypes           time:   [5.3315 ns 5.3342 ns 5.3367 ns]
+not/nfuint              time:   [2.3861 ns 2.3867 ns 2.3873 ns]
-not/etypes              time:   [3.8522 ns 3.8526 ns 3.8530 ns]

+shift/left/0/nfuint     time:   [2.4974 ns 2.4978 ns 2.4981 ns]
-shift/left/0/etypes     time:   [9.7666 ns 9.7678 ns 9.7692 ns]
+shift/left/7/nfuint     time:   [2.5193 ns 2.5196 ns 2.5199 ns]
-shift/left/7/etypes     time:   [12.425 ns 12.426 ns 12.428 ns]
+shift/left/65/nfuint    time:   [2.2779 ns 2.2832 ns 2.2905 ns]
-shift/left/65/etypes    time:   [11.685 ns 11.725 ns 11.775 ns]
+shift/left/511/nfuint   time:   [1.9075 ns 1.9083 ns 1.9091 ns]
-shift/left/511/etypes   time:   [5.6710 ns 5.6788 ns 5.6893 ns]

+shift/right/0/nfuint    time:   [2.4972 ns 2.4977 ns 2.4981 ns]
-shift/right/0/etypes    time:   [9.7640 ns 9.7645 ns 9.7651 ns]
+shift/right/7/nfuint    time:   [2.5281 ns 2.5284 ns 2.5286 ns]
-shift/right/7/etypes    time:   [12.409 ns 12.410 ns 12.411 ns]
+shift/right/65/nfuint   time:   [2.3753 ns 2.3755 ns 2.3757 ns]
-shift/right/65/etypes   time:   [11.878 ns 11.879 ns 11.880 ns]
+shift/right/511/nfuint  time:   [1.9077 ns 1.9088 ns 1.9098 ns]
-shift/right/511/etypes  time:   [5.7064 ns 5.7336 ns 5.7679 ns]

License

Licensed under either of Apache License, Version 2.0 or MIT License, at your option.

Core symbols most depended-on inside this repo

ident_to_ts
called by 48
constructor/src/utils.rs
pure_uint_list_to_ts
called by 44
constructor/src/utils.rs
defun
called by 32
constructor/src/fixed_uint/core/constructor.rs
implt
called by 21
constructor/src/fixed_uint/core/constructor.rs
implt
called by 20
constructor/src/fixed_hash/core/constructor.rs
pure_uint_to_ts
called by 17
constructor/src/utils.rs
defun
called by 17
constructor/src/fixed_hash/core/constructor.rs
attach_common
called by 5
constructor/src/fixed_uint/core/constructor.rs

Shape

Method 206
Function 86
Class 24
Enum 1

Languages

Rust99%
Python1%

Modules by API surface

fixed-uint-tests/src/props.rs31 symbols
constructor/src/fixed_uint/core/constructor.rs18 symbols
constructor/src/fixed_hash/core/constructor.rs18 symbols
fixed-hash-tests/src/props.rs16 symbols
constructor/src/fixed_uint/core/internal/public_conv.rs12 symbols
constructor/src/fixed_uint/core/internal/private_ops.rs11 symbols
fixed-uint-tests/tests/std_fmt.rs9 symbols
fixed-uint-tests/tests/prim_pow.rs9 symbols
fixed-uint-tests/tests/prim_checked.rs9 symbols
constructor/src/fixed_uint/core/builtin/std_fmt.rs9 symbols
constructor/src/fixed_uint/core/builtin/as_primitive.rs8 symbols
constructor/src/fixed_hash/core/internal/public_conv.rs7 symbols

For agents

$ claude mcp add rust-numext \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact