This file provides guidance to Claude Code (claude.ai/code) when working with the Python module.
The Python module depends on the C++ shared library (libtsfile). Build C++ first:
# From repo root ./mvnw clean package -P with-cpp -DskipTests
# Build everything via Maven (builds C++ then Python) ./mvnw clean verify -P with-python # Or build directly (after C++ is built) cd python python setup.py build_ext --inplace # Run tests pytest tests/ # Run a single test pytest tests/test_write_and_read.py -k "test_name" # Format code cd ../ && ./mvnw spotless:apply # Uses Black 26.3.1
python/tsfile/
├── __init__.py # Public API exports
├── constants.py # Enums: TSDataType, TSEncoding, Compressor, ColumnCategory
├── schema.py # TimeseriesSchema, DeviceSchema, TableSchema, ColumnSchema
├── tablet.py # Tablet class for batch columnar data
├── field.py / row_record.py # Row-based data structures
├── tag_filter.py # Tag filtering DSL for queries
├── tsfile_table_writer.py # High-level table writer API
├── utils.py # to_dataframe(), dataframe_to_tsfile()
├── exceptions.py # Custom exception types
│
├── tsfile_py_cpp.pyx # Cython core: Python ↔ C++ type conversion
├── tsfile_reader.pyx # Cython reader wrapper
├── tsfile_writer.pyx # Cython writer wrapper
├── tsfile_cpp.pxd # C++ interface declarations (cwrapper)
│
└── dataset/ # High-level multi-file API
├── dataframe.py # TsFileDataFrame (pandas-like interface)
├── timeseries.py # Timeseries, AlignedTimeseries
├── reader.py # Multi-file reader coordination
└── merge.py # K-way merge for overlapping time ranges
*.pyx) → Pure Python APIsetup.py copies pre-built C++ headers and shared libraries from ../cpp/target/build/cwrapper/tsfile_cwrapper.h from the C++ modulecheck_error() in tsfile_py_cpp.pyxpython/tests/, 19 test files covering write, read, filtering, DataFrame conversion, and Arrow formatEvery new file must include the Apache License 2.0 header at the top. For Python files, use # line comments. For .pyx/.pxd files, also use # comments. See any existing file for the exact wording.
Co-Authored-By trailer to commit messages.