Skip to content

Commit

Permalink
implemented VERSION property and shrink_to_fit() method
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed Aug 7, 2023
1 parent 9a5b77a commit b2857d0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/annotationstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ impl PyAnnotationStore {
self.map(|store| Ok(store.datasets_len()))
}

fn shrink_to_fit(&mut self) -> PyResult<()> {
self.map_mut(|store| Ok(store.shrink_to_fit(true)))
}

/* (too low, level, removing)
/// Applies a selector to the annotation store and returns the target(s)
/// May return a multitude of types depending on the selector, returns
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ use crate::resources::{PyCursor, PyOffset, PyTextResource};
use crate::selector::{PySelector, PySelectorKind};
use crate::textselection::{PyTextSelection, PyTextSelectionOperator};

const VERSION: &'static str = env!("CARGO_PKG_VERSION");

#[pymodule]
fn stam(py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add("StamError", py.get_type::<PyStamError>())?;
m.add("VERSION", VERSION)?;
m.add_class::<PyAnnotationStore>()?;
m.add_class::<PyAnnotationDataSet>()?;
m.add_class::<PyAnnotationData>()?;
Expand Down
2 changes: 2 additions & 0 deletions stam.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class AnnotationStore:
def resources_len(self) -> int:
"""Returns the number of text resources in the store (not substracting deletions)"""

def shrink_to_fit(self):
"""Reallocates internal data structures to tight fits to conserve memory space (if necessary). You can use this after having added lots of annotations to possibly reduce the memory consumption."""

class Annotation:
"""
Expand Down

0 comments on commit b2857d0

Please sign in to comment.