-
Notifications
You must be signed in to change notification settings - Fork 14
adding a small integer to a BigInt with operate! allocates #353
Copy link
Copy link
Open
Description
Presumably the small integer is being converted to BigInt by mistake. It is possible to add some small ints to a BigInt directly using Base.GMP.MPZ.add_si! (or Base.GMP.MPZ.add_ui!).
julia> using MutableArithmetics: MutableArithmetics as MA
julia> x = BigInt(0)
0
julia> @timev MA.operate!(+, x, 1)
0.086091 seconds (135.80 k allocations: 7.078 MiB, 99.88% compilation time)
elapsed time (ns): 8.6090543e7
gc time (ns): 0
bytes allocated: 7421600
pool allocs: 135768
non-pool GC allocs: 1
malloc() calls: 34
realloc() calls: 1
free() calls: 0
minor collections: 0
full collections: 0
1
julia> @timev MA.operate!(+, x, 1)
0.000022 seconds (2 allocations: 56 bytes)
elapsed time (ns): 21772.0
gc time (ns): 0
bytes allocated: 56
pool allocs: 1
non-pool GC allocs: 0
malloc() calls: 1
free() calls: 0
minor collections: 0
full collections: 0
2Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels