Repository navigation
Conversation
Use map for normal and vertex float conversions. Skip explicit vertex tuples while preserving nine-digit formatting and write order. Co-Authored-By: Aiden <aiden@weco.ai>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
BaseStl._write_asciifor Python ASCII mesh saves.map(float, ...)and skip explicit vertex tuples while keeping the same output formatting.python -m pytest tests/test_ascii.py --basetemp=tmp: 17 passed, 3 skipped.What & Why
The writer used Python generator expressions to convert each normal and vertex component to a float.
It also built a tuple for each vertex before passing its values to the formatter.
Use
mapfor these conversions and pass vertex values directly to the existing formatter.Keep normal conversion before vertex access, the same nine significant digits, and the same write order.
Validation
Measured on Linux with Python 3.12.13 and NumPy 2.5.4, using an isolated benchmark core.
The save workload writes a 20,000-triangle surface to
BytesIOthroughMesh.save(mode=Mode.ASCII), plus seven small regression cases.The read rows use the repository's Stanford Dragon benchmark, with five iterations per setting.
These statistics summarize the save measurements:
The read path is unchanged; the read measurements show mixed variation, and this PR claims no read improvement.
Read benchmark reproduction:
python benchmarks/benchmark_ascii_read.py --iterations 5The full suite (
python -m pytest) passed with 1,032 passed and 23 skipped after installing the package with test dependencies.The initial source-only environment lacked distribution metadata and failed two version tests; installing the package resolved both failures.
Ruff lint, Ruff formatting, and the pinned
ty==0.0.56check passed.Why this is safe and easy to maintain
The patch changes four expressions and adds no branches or helpers.
It preserves float conversion, output bytes, names, and optional C writer dispatch.
ASCII tests cover round trips and tiny coordinates; exact-output checks also cover empty meshes, Unicode names, signed zero, and text-stream errors.
AI assistance
This PR was prepared with AI assistance from Aiden. Candidates were tracked with Weco Observe.
Weco share link: https://dashboard.weco.ai/share/hTONguMVsnWUU1pW-8IgLbU60AaqeXCw