Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 43 additions & 72 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ name = "fastexcel"
crate-type = ["cdylib", "rlib"]

[dependencies]
arrow-array = { version = "^56.2.0", features = ["ffi"], optional = true }
arrow-pyarrow = { version = "^56.2.0", optional = true }
arrow-schema = { version = "^56.1.0", optional = true }
arrow-array = { version = "^57", features = ["ffi"], optional = true }
arrow-pyarrow = { version = "^57", optional = true }
arrow-schema = { version = "^57", optional = true }
calamine = { version = "^0.31.0", features = ["chrono"] }
chrono = { version = "^0.4.42", default-features = false }
log = "^0.4"
Expand All @@ -37,9 +37,9 @@ polars-core = { version = ">=0.50", default-features = false, features = [
"dtype-datetime",
"dtype-duration",
], optional = true }
pyo3 = { version = "^0.25", features = ["abi3-py39"], optional = true }
pyo3-arrow = { version = "0.11", default-features = false, optional = true }
pyo3-log = { version = "^0.12.4", optional = true }
pyo3 = { version = "^0.26", features = ["abi3-py39"], optional = true }
pyo3-arrow = { version = "^0.14", default-features = false, optional = true }
pyo3-log = { version = "^0.13.1", optional = true }

[dev-dependencies]
anyhow = "1.0.100"
Expand Down
2 changes: 2 additions & 0 deletions python/tests/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ def test_fallback_infer_dtypes(mocker: MockerFixture) -> None:
"Could not determine dtype for column 1, falling back to string",
mocker.ANY,
mocker.ANY,
mocker.ANY,
mocker.ANY,
)

assert sheet.available_columns() == [
Expand Down
2 changes: 1 addition & 1 deletion src/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ pub(crate) fn generate_row_selector(
SkipRows::Callable(_func) => {
// Call the Python function for each row to determine if it should be skipped
// The callable should receive data-relative row indices (0, 1, 2, ...)
pyo3::Python::with_gil(|py| {
pyo3::Python::attach(|py| {
Ok(RowSelector::Filtered(
(offset..limit)
.enumerate()
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ fn py_read_excel<'py>(source: &Bound<'_, PyAny>, py: Python<'py>) -> PyResult<Ex
use py_errors::IntoPyResult;

if let Ok(path) = source.extract::<String>() {
py.allow_threads(|| ExcelReader::try_from_path(&path))
py.detach(|| ExcelReader::try_from_path(&path))
.with_context(|| format!("could not load excel file at {path}"))
.into_pyresult()
} else if let Ok(bytes) = source.extract::<&[u8]>() {
py.allow_threads(|| ExcelReader::try_from(bytes))
py.detach(|| ExcelReader::try_from(bytes))
.with_context(|| "could not load excel file for those bytes")
.into_pyresult()
} else {
Expand Down
14 changes: 6 additions & 8 deletions src/types/excelreader/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl ExcelReader {

if eager && self.sheets.supports_by_ref() {
let range = py
.allow_threads(|| {
.detach(|| {
self.sheets
.with_header_row(calamine_header_row)
.worksheet_range_ref(&sheet_meta.name)
Expand All @@ -96,7 +96,7 @@ impl ExcelReader {
Pagination::try_new(opts.skip_rows, opts.n_rows, &range).into_pyresult()?;
let header = Header::new(data_header_row, opts.column_names);
let rb = py
.allow_threads(|| {
.detach(|| {
Self::load_sheet_eager(
&range.into(),
pagination,
Expand All @@ -112,7 +112,7 @@ impl ExcelReader {
#[cfg(feature = "pyarrow")]
{
use arrow_pyarrow::ToPyArrow;
rb.to_pyarrow(py).map(|py_object| py_object.into_bound(py))
rb.to_pyarrow(py)
}
#[cfg(not(feature = "pyarrow"))]
{
Expand All @@ -122,7 +122,7 @@ impl ExcelReader {
}
} else {
let range = py
.allow_threads(|| {
.detach(|| {
self.sheets
.with_header_row(calamine_header_row)
.worksheet_range(&sheet_meta.name)
Expand Down Expand Up @@ -168,14 +168,12 @@ impl ExcelReader {
eager: bool,
py: Python<'py>,
) -> PyResult<Bound<'py, PyAny>> {
let excel_table = py
.allow_threads(|| self.load_table(name, opts))
.into_pyresult()?;
let excel_table = py.detach(|| self.load_table(name, opts)).into_pyresult()?;

if eager {
#[cfg(feature = "pyarrow")]
{
Ok(excel_table.to_arrow(py)?.into_bound(py))
Ok(excel_table.to_arrow(py)?)
}
#[cfg(not(feature = "pyarrow"))]
{
Expand Down
Loading