-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add function barrier in npzreadarray and introduce readheader (#44)
This change does two things: - Make the `Header` type parametric and concrete: this seems to cut down on allocations while reading arrays On master: ```julia julia> npzwrite("abc.npy", ones(3,4)); julia> @Btime npzread("abc.npy"); 23.639 μs (91 allocations: 5.80 KiB) ``` After this PR: ```julia julia> @Btime npzread("abc.npy"); 20.911 μs (80 allocations: 5.28 KiB) ``` The difference in run-time is marginal. - Introduce a function `readheader` that returns the header. This might be convenient to get the `eltype` and `size` of the array without reading it in (eg. to pre-allocate an array of the correct size). This function is not exported. ```julia julia> npzwrite("abc.npy", ones(3,4)); julia> NPZ.readheader("abc.npy") NPZ.Header{Float64,2,typeof(ltoh)}(ltoh, true, (3, 4)) julia> NPZ.readheader("abc.npy") |> size (3, 4) julia> NPZ.readheader("abc.npy") |> eltype Float64 ```
- Loading branch information
Showing
3 changed files
with
88 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8834d3c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
8834d3c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/27619
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: