Metadata-Version: 2.4
Name: fastdxf
Version: 0.1.0
Requires-Dist: ezdxf>=1.4.5,<2
Requires-Dist: numpy>=1.23.5
Summary: Rust-accelerated DXF document loading and NumPy LINE extraction for ezdxf
Requires-Python: >=3.11
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM

# fastdxf

fastdxf accelerates `ezdxf.readfile()` with Rust and returns an editable `ezdxf.document.Drawing`. It also extracts modelspace LINE endpoints directly into a NumPy array.

## Installation

Install fastdxf from PyPI with Python 3.11 or later.

```bash
python -m pip install fastdxf
```

The two document-loading options below are available in fastdxf 0.1.0. CPython 3.12 wheels target Linux x86-64 (glibc 2.28+), Windows x86-64 and macOS 11+ on Apple silicon. Source builds require Rust. To install from a checkout, run `python -m pip install .`. [PyPI release files](https://pypi.org/project/fastdxf/#files)

## Run an existing ezdxf script

Use the module runner to launch the script with its existing imports.

```bash
python -m fastdxf edit.py input.dxf output.dxf
```

Inside that process, `import ezdxf`, `from ezdxf import readfile` and `from ezdxf.filemanagement import readfile` use the accelerated reader, including in the script's helper modules. Arguments after the script name are passed to the script.

Alternatively, change the import to `import fastdxf as ezdxf` and run the script with the usual `python edit.py` command.

```python
import fastdxf as ezdxf
from ezdxf.math import Vec3

doc = ezdxf.readfile("drawing.dxf")
doc.modelspace().add_line(Vec3(0, 0), Vec3(3, 4))
doc.saveas("edited.dxf")
```

Both options use the Rust document reader with ezdxf 1.4.5 for ASCII R12, R2007, R2010, R2013 and R2018. Binary DXF, other ezdxf or DXF versions, and encodings, error handlers or structures outside the native reader use the installed ezdxf reader. Queries, edits and saves use ezdxf's own document and entity classes. Use the usual `ezdxf.*` imports for submodules.

## Document loading performance

| Mixed drawing | ezdxf read | fastdxf read (import / runner) | Full script speedup (import / runner) |
|---|---:|---:|---:|
| R2010, 7.54 MB | 1,822 ms | 1,239 / 1,242 ms | 1.22× / 1.20× |
| R2018, 2.17 MB | 375 ms | 251 / 246 ms | 1.16× / 1.16× |

The full script starts Python, reads the drawing, queries and edits a modelspace LINE, saves the file, and exits. The PR10 wheel measurements use the median of six rotated trials on Linux x86-64 with CPython 3.12.3 and ezdxf 1.4.5 with C extensions. All edited files matched the official ezdxf output byte for byte. [Benchmark inputs, wheel hash and timings](https://github.com/monozukuri-ai/fastdxf/blob/eff3b9c/docs/document-benchmark.ja.md#pr10-の無編集起動)

## Extract LINE endpoints

```python
import fastdxf

segments = fastdxf.read_lines("drawing.dxf")
starts, ends = segments[:, 0], segments[:, 1]
```

`read_lines(path)` returns a read-only, C-contiguous `float64` array with shape `(N, 2, 3)`. Each row holds the WCS start and end of a LINE directly in modelspace, in layout order. An empty selection has shape `(0, 2, 3)`. The native LINE reader targets the same five ASCII DXF versions. Binary DXF, other versions, and layouts it cannot resolve use ezdxf's reader.

## LINE extraction performance

| Mixed drawing | Direct modelspace LINEs | fastdxf | Faster of the two iterdxf readers | Speedup |
|---|---:|---:|---:|---:|
| R2010, 7.54 MB | 11,556 | 45.31 ms | 888.59 ms | 19.61× |
| R2018, 2.17 MB | 2,039 | 8.68 ms | 189.17 ms | 21.80× |

These are the PR3 release-wheel measurements on Linux x86-64, Core i9-13900H, CPython 3.12.3 and ezdxf 1.4.5 with C extensions. Times cover opening the file through returning the NumPy array, using one warm-up and the median of five rotated trials. The indexed iterdxf measurement includes building the index. All methods matched the ordered endpoint bits from ezdxf. [Benchmark details and reproduction](https://github.com/monozukuri-ai/fastdxf/blob/a8898803f6f4635f45ca94247818170bd764fffa/docs/wheel-benchmark.ja.md)

Maintainers can rehearse a release or publish a tagged build. [Release instructions](https://github.com/monozukuri-ai/fastdxf/blob/main/docs/releasing.md)

