-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
Python's hashlib.sha256(data).hexdigest()
is 10x faster than SHA.jl's sha256(data)
on my computer:
In [8]: %timeit hashlib.sha256(data).hexdigest()
53.8 µs ± 6.88 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)
julia> @benchmark sha256(data)
BenchmarkTools.Trial: 8884 samples with 1 evaluation.
Range (min … max): 514.644 μs … 913.010 μs ┊ GC (min … max): 0.00% … 0.00%
Time (median): 518.341 μs ┊ GC (median): 0.00%
Time (mean ± σ): 561.483 μs ± 99.395 μs ┊ GC (mean ± σ): 0.00% ± 0.00%
This is presumably (haven't checked though) because Python's underlying C library uses SHA-specific CPU instructions, where as this package does not.
This might not be possible to fix in current versions of Julia, but given that we see a 10x performance difference, this is something Julia needs to support eventually (and probably will). When that time comes, this package should be updated.
This issue was discovered by @jonalm
Metadata
Metadata
Assignees
Labels
No labels