Created
June 18, 2024 17:52
-
-
Save lmmx/17bbfcddd82247b8451129df6af335e4 to your computer and use it in GitHub Desktop.
Simple `.npy` file format reading (to benchmark against `np.load`)
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
[package] | |
name = "hello_npy" | |
version = "0.1.0" | |
edition = "2021" | |
[dependencies] | |
npyz = "0.8.3" |
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
use npyz::NpyFile; | |
fn read_npy_file(file_path: &str) -> Vec<f64> { | |
let reader = std::io::BufReader::new(std::fs::File::open(file_path).unwrap()); | |
NpyFile::new(reader).unwrap().into_vec().unwrap() | |
} | |
fn main() { | |
let file_path = "/path/to/your/file.npy"; | |
let _data = read_npy_file(file_path); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment