Skip to main content

Experimental pyisyntax fork with positional I/O and bounded codeblock prefetching

Project description

pyisyntax-fastio

[!IMPORTANT] This is an experimental, unofficial fork of pyisyntax. It preserves the public from isyntax import ISyntax API while evaluating positional I/O and bounded codeblock prefetching. The 64 KiB coalescing policy is enabled in this alpha but has not been accepted as a stable-release default; true OS-cold HDD validation is still pending.

A Python library for working with pathology images in the iSyntax file format, powered by libisyntax.

Installation

Pre-release wheels are distributed through the GitHub Releases page. Download the file matching your operating system and architecture, then run:

$ python -m pip install ./pyisyntax_fastio-0.2.0a1-<platform>.whl

The Windows x86-64, Linux x86-64, and macOS Intel/Apple Silicon wheels use the CPython Stable ABI (cp310-abi3) and require Python 3.10 or newer. CI tests cover CPython 3.10, 3.11, and 3.12.

Alternatively, install from a checked-out source tree with its submodule initialized:

$ git submodule update --init --recursive
$ python -m pip install .

This fork has not been published to PyPI. The existing pip install pyisyntax command installs the upstream project, not this experimental fork.

Usage

Read and display a region of the WSI via Pillow.

from isyntax import ISyntax
import PIL.Image

with ISyntax.open("my_file.isyntax") as isyntax:
    # Read pixels from the specified region into a numpy array
    pixels = isyntax.read_region(500, 500, 400, 200, level=4)
    # Convert numpy array into a PIL image
    pil_image = PIL.Image.fromarray(pixels)
    # Show the image
    pil_image.show()

Extract and save the associated macro image.

from isyntax import ISyntax

with ISyntax.open("my_file.isyntax") as isyntax:
    # The macro image will be returned as compressed JPEG data.
    jpeg_data = isyntax.read_macro_image_jpeg()
    # This JPEG data can be written directly to a file.
    with open("macro_image.jpg", "wb") as f:
        f.write(jpeg_data)
    # Alternatively, you could decompress the data using Pillow:
    # pil_image = PIL.Image.open(io.BytesIO(jpeg_data), formats=["JPEG"])

I/O backends

ISyntax.open(path) uses a native positional file source. Seekable Python file-like objects remain supported through ISyntax(stream, n_bytes) and use one atomic read_at callback per physical request. Both paths share the same decoder and strict short-read handling.

Tile reads plan missing codeblocks before decoding, read them in file-offset order, and merge only ranges separated by at most 64 KiB. A merged range is also capped at 1 MiB, limiting over-read and temporary memory use. These are private implementation details; the public NumPy/RGBA API is unchanged.

Threading safety

Pixel reads must currently run on the same Python thread that first opens an iSyntax slide. The vendored libisyntax initializes temporary-memory state only for that caller thread; calling read_tile() or read_region() from another Python thread can otherwise crash the process. pyisyntax temporarily rejects such calls with RuntimeError until the native library provides safe per-caller-thread initialization. Opening and reading a slide inside one worker thread is supported as long as that worker is also the first thread to initialize libisyntax in the process.

Provenance and licensing

This fork retains the upstream pyisyntax history and MIT license. Its modified native backend is based on libisyntax and retains the BSD-2-Clause license. See THIRD_PARTY_NOTICES.md for attribution and source links. This project is not an official release of either upstream project.

Development

Dependency management

To set up a development environment from the lock file:

  1. Ensure that you have uv installed.
  2. Create the virtual environment:
    $ uv sync --frozen
    

To modify pyisyntax project dependencies:

  1. Edit dependencies in pyproject.toml.
  2. Update the lock file using uv:
    $ uv lock
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyisyntax_fastio-0.2.0a1.tar.gz (267.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyisyntax_fastio-0.2.0a1-cp310-abi3-win_amd64.whl (101.0 kB view details)

Uploaded CPython 3.10+Windows x86-64

pyisyntax_fastio-0.2.0a1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (608.3 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

pyisyntax_fastio-0.2.0a1-cp310-abi3-macosx_11_0_arm64.whl (148.9 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

pyisyntax_fastio-0.2.0a1-cp310-abi3-macosx_10_9_x86_64.whl (160.4 kB view details)

Uploaded CPython 3.10+macOS 10.9+ x86-64

File details

Details for the file pyisyntax_fastio-0.2.0a1.tar.gz.

File metadata

  • Download URL: pyisyntax_fastio-0.2.0a1.tar.gz
  • Upload date:
  • Size: 267.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyisyntax_fastio-0.2.0a1.tar.gz
Algorithm Hash digest
SHA256 46f72b1ff25731458229daba94692994145a6647387a1ba79d4c8f294a8f54d9
MD5 749d484b0be449aac12c48c2e890be7e
BLAKE2b-256 9b74f9041c81e0f1ee7b5e7ca473285b8bf54fcc2a7d28d796fba437674d6ee5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyisyntax_fastio-0.2.0a1.tar.gz:

Publisher: release.yml on chaosbeagle/pyisyntax-fastio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyisyntax_fastio-0.2.0a1-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for pyisyntax_fastio-0.2.0a1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 864cc2f4d783d7fda05390947df89bd982824596c3404083eae376a7b46511b4
MD5 ecaefe30956530ce62379b151c7f2c04
BLAKE2b-256 39101d1613ee7fd0498102b4febebedcac4496ad3acc0486cb6869e422a1d185

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyisyntax_fastio-0.2.0a1-cp310-abi3-win_amd64.whl:

Publisher: release.yml on chaosbeagle/pyisyntax-fastio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyisyntax_fastio-0.2.0a1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyisyntax_fastio-0.2.0a1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 def1f121788bef811c4e0877c00d30af3dd1166e43946daa037698507c96c8a8
MD5 67b473924142bb550dda5cda4524a509
BLAKE2b-256 7771bea553ff5a8fa48672fa96b270d8ed67e5860c2ba659a30eb15f2fed1370

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyisyntax_fastio-0.2.0a1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on chaosbeagle/pyisyntax-fastio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyisyntax_fastio-0.2.0a1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyisyntax_fastio-0.2.0a1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b7ff2a9f1201c72c57f21e08e43385c67e94e85be970012e7f15f39269ea5946
MD5 408a5740c31cd07272d42da948095d2f
BLAKE2b-256 d69784dc32db38e6b7e2f4514df583dc6e41e32f954833422020b612fb7aee00

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyisyntax_fastio-0.2.0a1-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on chaosbeagle/pyisyntax-fastio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyisyntax_fastio-0.2.0a1-cp310-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyisyntax_fastio-0.2.0a1-cp310-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 826ba64cf72190f012f5ac11d4e61d1afc60821e13c302104827ce7a2c0e7977
MD5 bfe9790ba840f56b0c10806e882bda39
BLAKE2b-256 09657fa3d3364a06d2bd6032e709846a767839963168acd8a2e29737cded5ee2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyisyntax_fastio-0.2.0a1-cp310-abi3-macosx_10_9_x86_64.whl:

Publisher: release.yml on chaosbeagle/pyisyntax-fastio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page