Skip to content

Commit

Permalink
Memory map as private pure copy. (#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
Narsil authored Jan 2, 2025
1 parent b4a9ec7 commit e61e872
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bindings/python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "safetensors-python"
version = "0.5.0-dev.0"
version = "0.5.1-dev.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ impl Open {

// SAFETY: Mmap is used to prevent allocating in Rust
// before making a copy within Python.
let buffer = unsafe { MmapOptions::new().map(&file)? };
let buffer = unsafe { MmapOptions::new().map_copy_read_only(&file)? };

let (n, metadata) = SafeTensors::read_metadata(&buffer).map_err(|e| {
SafetensorError::new_err(format!("Error while deserializing header: {e:?}"))
Expand Down
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
postShellHook = ''
unset SOURCE_DATE_EPOCH
'';
LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${pkgs.stdenv.cc.cc.lib}/lib";
};

}
Expand Down
2 changes: 1 addition & 1 deletion safetensors/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "safetensors"
version = "0.5.0-dev.0"
version = "0.5.1-dev.0"
edition = "2021"
homepage = "https://github.com/huggingface/safetensors"
repository = "https://github.com/huggingface/safetensors"
Expand Down

0 comments on commit e61e872

Please sign in to comment.