pyminiply is a Python library for rapidly reading PLY files. It is a Python wrapper around the fast C++ PLY reading library provided by miniply. Thanks @vilya!
The main advantage of pyminiply over other PLY reading libraries is its performance. See the benchmarks below for more details.
Installation
The recommended way to install pyminiply is via PyPI:
pip install pyminiply
Optionally with PyVista:
pip install pyminipl[pyvista]
You can also clone the repository and install it from source:
git clone https://github.com/pyvista/pyminiply.git
cd pyminiply
git submodule update --init --recursive
pip install .
Usage
Load in the vertices, indices, normals, UV, and color information from a PLY file:
>>> import pyminiply
>>> vertices, indices, normals, uv, color = pyminiply.read("example.ply")
>>> vertices
array([[ 5.0000000e-01, -5.0000000e-01, -5.5511151e-17],
[ 4.0000001e-01, -5.0000000e-01, -4.4408922e-17],
[ 3.0000001e-01, -5.0000000e-01, -3.3306692e-17],
...,
[-4.2500001e-01, 5.0000000e-01, 4.7184480e-17],
[-4.7499999e-01, 4.4999999e-01, 5.2735593e-17],
[-5.0000000e-01, 4.2500001e-01, 5.5511151e-17]], dtype=float32)
>>> indices
array([[ 0, 442, 441],
[ 442, 122, 443],
[ 443, 121, 441],
...,
[1677, 438, 1679],
[1679, 439, 1676],
[1677, 1679, 1676]], dtype=int32)
>>> normals
array([[-1.110223e-16, 0.000000e+00, -1.000000e+00],
[-1.110223e-16, 0.000000e+00, -1.000000e+00],
[-1.110223e-16, 0.000000e+00, -1.000000e+00],
...,
[-1.110223e-16, 0.000000e+00, -1.000000e+00],
[-1.110223e-16, 0.000000e+00, -1.000000e+00],
[-1.110223e-16, 0.000000e+00, -1.000000e+00]], dtype=float32)
>>> uv
array([[0. , 0. ],
[0.1 , 0. ],
[0.2 , 0. ],
...,
[0.92499995, 1. ],
[0.975 , 0.95 ],
[1. , 0.92499995]], dtype=float32)
>>> color
array([[ 0, 0, 0],
[ 0, 0, 0],
[ 0, 0, 0],
...,
[254, 254, 254],
[254, 254, 254],
[255, 255, 255]], dtype=uint8)
You can also read in the PLY file as a PyVista PolyData and immediately plot it.
>>> import pyminiply
>>> mesh = pyminiply.read_as_mesh("example.ply")
>>> mesh
PolyData (0x7f0653579c00)
N Cells: 200
N Points: 121
N Strips: 0
X Bounds: -5.000e-01, 5.000e-01
Y Bounds: -5.000e-01, 5.000e-01
Z Bounds: -5.551e-17, 5.551e-17
N Arrays: 2
>>> mesh.plot()
Benchmark
The main reason behind writing yet another PLY file reader for Python is to leverage the highly performant miniply library.
There is already a benchmark demonstrating how miniply outperforms in comparison to competing C and C++ libraries at ply_io_benchmark when reading PLY files. The benchmark here shows how pyminiply performs relative to other Python PLY file readers.
Here are the timings from reading in a 1,000,000 point binary PLY file on an Intel i9-14900KF:
Library |
Time (seconds) |
|---|---|
pyminiply |
0.027 |
open3d |
0.102 |
PyVista (VTK) |
0.214 |
meshio |
0.249 |
plyfile |
4.039 |
Benchmark source:
import time
from timeit import timeit
import numpy as np
import pyvista as pv
import pyminiply
import plyfile
import meshio
import open3d
number = 10
filename = "tmp.ply"
mesh = pv.Plane(i_resolution=999, j_resolution=999).triangulate()
mesh.clear_data()
mesh.save(filename)
telap = timeit(lambda: pyminiply.read(filename), number=number)
print(f"pyminiply: {telap/number:.3f}")
telap = timeit(lambda: open3d.io.read_point_cloud(filename), number=number)
print(f"open3d: {telap/number:.3f}")
telap = timeit(lambda: pv.read(filename), number=number)
print(f"VTK/PyVista: {telap/number:.3f}")
telap = timeit(lambda: meshio.read(filename), number=number)
print(f"meshio: {telap/number:.3f}")
# plyfile
number = 3 # less because it takes a while
telap = timeit(lambda: plyfile.PlyData.read(filename), number=number)
print(f"plyfile: {telap/number:.3f}")
Comparison with VTK and PyVista
Here’s an additional benchmark comparing VTK/PyVista with pyminiply:
import numpy as np
import time
import pyvista as pv
import matplotlib.pyplot as plt
import pyminiply
times = []
filename = 'tmp.ply'
for res in range(50, 800, 50):
mesh = pv.Plane(i_resolution=res, j_resolution=res).triangulate().subdivide(2)
mesh.clear_data()
mesh.save(filename)
tstart = time.time()
pv_mesh = pv.read(filename)
vtk_time = time.time() - tstart
tstart = time.time()
ply_mesh = pyminiply.read_as_mesh(filename)
ply_reader_time = time.time() - tstart
assert np.allclose(pv_mesh['Normals'], ply_mesh['Normals'])
assert np.allclose(pv_mesh.points, ply_mesh.points)
assert np.allclose(pv_mesh._connectivity_array, ply_mesh._connectivity_array)
times.append([mesh.n_points, vtk_time, ply_reader_time])
print(times[-1])
times = np.array(times)
plt.figure(1)
plt.title('PLY load time')
plt.plot(times[:, 0], times[:, 1], label='VTK')
plt.plot(times[:, 0], times[:, 2], label='pyminiply')
plt.xlabel('Number of Points')
plt.ylabel('Time to Load (seconds)')
plt.legend()
plt.figure(2)
plt.title('PLY load time (Log-Log)')
plt.loglog(times[:, 0], times[:, 1], label='VTK')
plt.loglog(times[:, 0], times[:, 2], label='pyminiply')
plt.xlabel('Number of Points')
plt.ylabel('Time to Load (seconds)')
plt.legend()
plt.show()
License and Acknowledgments
This project relies on miniply and credit goes to the original author for the excellent C++ library. That work is licensed under the MIT License.
The work in this repository is also licensed under the MIT License.
Support
If you are having issues, please feel free to raise an Issue.
Metadata
Release files for pyminiply 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyminiply-0.2.3.tar.gz | 26.8 kB | Details |
Built distributions (wheels)
Total release size: 1.3 MB
Release files / pyminiply-0.2.3.tar.gz
| Download URL | pyminiply-0.2.3.tar.gz |
|---|---|
| Size | 26.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f024b81bd222a03840d6ff9f264a565cea30c7cb02cc197b83dab99e83ddbfe7
|
|
BLAKE2b-256 checksum How to use checksums |
b146cc352a40595c7c736ccb6b07e6d7a4db9b71087dcf5caef2343150d0d0db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / pyminiply-0.2.3-cp313-cp313-win_amd64.whl
| Download URL | pyminiply-0.2.3-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 57.7 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6c91a18ac54bd17f7bedccc5a60713459fcdad497dfb0520b2055472ca3b0277
|
|
BLAKE2b-256 checksum How to use checksums |
8f9cef4cd627b1bd7fcd9471897cd45448feb25b6b40d526c8c1d82b9a2b262b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / pyminiply-0.2.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyminiply-0.2.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 82.5 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
d27b85b286c44c5a71ee3b63815b5a05bdfbd2cb5d6834703a5c165c1ca29045
|
|
BLAKE2b-256 checksum How to use checksums |
92e85b518f1a32b900798ad0e06b2336f7f9dbf2a6f4c8267749f2f68569ebf0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / pyminiply-0.2.3-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | pyminiply-0.2.3-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 56.4 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
df88bf866729d75a468567e56eb47d2adb4fd2d445c162d032ea32a0ecf87001
|
|
BLAKE2b-256 checksum How to use checksums |
cbfede90f1a95ccba30a3045e3082e3c68b7e1a1fb9a3c1d0aba7ce77ab5c879
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / pyminiply-0.2.3-cp313-cp313-macosx_10_14_x86_64.whl
| Download URL | pyminiply-0.2.3-cp313-cp313-macosx_10_14_x86_64.whl |
|---|---|
| Size | 62.0 kB |
| Tags | CPython 3.13 macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
4a699b357a02441a588fb7afd1528693db95c4016b55983546c49b77bf7e3704
|
|
BLAKE2b-256 checksum How to use checksums |
85134a068f6fc1f5def93895640ecc62cccd28b1bb8b2de693ca34ea09304b44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / pyminiply-0.2.3-cp312-cp312-win_amd64.whl
| Download URL | pyminiply-0.2.3-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 57.7 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
83e0d12efb77770ad2041244129c080549cf13aac6f115ce12c6f305b484a838
|
|
BLAKE2b-256 checksum How to use checksums |
66c193eeeaed0ccd4f085d789270d17a88b2d328f6ef8d83cffb7fdcdbe700e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / pyminiply-0.2.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyminiply-0.2.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 82.5 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
b441d09e4e1f6e4237e476263ac85382d6a0419f5e04aa84c1786731baea39b5
|
|
BLAKE2b-256 checksum How to use checksums |
eb83bd63ec25a98b763fba1b4721c7d3b9183042cd6f5b3abac6ee5aa1a10b6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / pyminiply-0.2.3-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | pyminiply-0.2.3-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 56.4 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e4ca7915c329d2d1b63334909544c45eeb8b037e1986edfc7e4a3c2514a01e57
|
|
BLAKE2b-256 checksum How to use checksums |
836fb195fcde1f10a1f703a7d7d0399365374b56b5ec3e00cef08474fe1dbd39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / pyminiply-0.2.3-cp312-cp312-macosx_10_14_x86_64.whl
| Download URL | pyminiply-0.2.3-cp312-cp312-macosx_10_14_x86_64.whl |
|---|---|
| Size | 62.0 kB |
| Tags | CPython 3.12 macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
9ed38b42debbc75e4bd6d8bc54d196492e5315435ea2c9de9b42e81286b51b29
|
|
BLAKE2b-256 checksum How to use checksums |
92606b9f438288e6271b74b524533008fe8aa840c7aa36c4f2f107cca95aed39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / pyminiply-0.2.3-cp311-cp311-win_amd64.whl
| Download URL | pyminiply-0.2.3-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 59.2 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
0d0c0c1e4cbb2b16d59fce51e319072c81f37356ea26383d8d7a558d110d1345
|
|
BLAKE2b-256 checksum How to use checksums |
2b460fb56049b5c87ea405da261e2c49fad2fc9b6cf210be17166ca0246acb24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / pyminiply-0.2.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyminiply-0.2.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 85.3 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
d636691ed02b437b0ebe56a45deb31dc03c1a5be6bbc4ba87f49eb15cabaf8db
|
|
BLAKE2b-256 checksum How to use checksums |
d408a219b32dc1cf018200ee6fc3ecea6fae1f5c8cef4eb0452e3d7c205b24d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / pyminiply-0.2.3-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | pyminiply-0.2.3-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 57.9 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
6dc14f26073efc59c50cdfc6472ba7f0896f50f7c39d7259290e29c48c7c66da
|
|
BLAKE2b-256 checksum How to use checksums |
46ac38830e27a3bb3dba6e647964fe692c331ab930cda18d357eff1b98abed28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / pyminiply-0.2.3-cp311-cp311-macosx_10_14_x86_64.whl
| Download URL | pyminiply-0.2.3-cp311-cp311-macosx_10_14_x86_64.whl |
|---|---|
| Size | 63.6 kB |
| Tags | CPython 3.11 macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
3db88e20cd750dfc4c04b011dcdd95315ed00bc2914ae899bea957705c6bd5a7
|
|
BLAKE2b-256 checksum How to use checksums |
c82b99a75efa034bbd3d750a1dc3d5362078adc6bd439f279a2e575a4885d4b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / pyminiply-0.2.3-cp310-cp310-win_amd64.whl
| Download URL | pyminiply-0.2.3-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 59.3 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
05bc8c6b73b1513e01f8e09de971394646ef17749863345df0c825d92d72a5b2
|
|
BLAKE2b-256 checksum How to use checksums |
a980ffcac89c2054ba359212dba76aedc85ad0816ea6dcb3b439e6658d0327b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / pyminiply-0.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyminiply-0.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 85.5 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
7351097b4fcbba4d89b59ee1407c8bb934759d2a570610e94c37ef07339558cf
|
|
BLAKE2b-256 checksum How to use checksums |
e38cb2f0aad3fa4c9d92ef52dea6fd963e2f5871a400faf4e6283512ddeab9e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / pyminiply-0.2.3-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | pyminiply-0.2.3-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 58.0 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
7cc6fd2b033a79ecfc9de4c928e7946d4ccf1bbe7bb3ef2d96568d6e4a765595
|
|
BLAKE2b-256 checksum How to use checksums |
d1e030cd646440024c82a5d036a1d88a47bd7ef30769499caf76688f80837bdb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / pyminiply-0.2.3-cp310-cp310-macosx_10_14_x86_64.whl
| Download URL | pyminiply-0.2.3-cp310-cp310-macosx_10_14_x86_64.whl |
|---|---|
| Size | 63.8 kB |
| Tags | CPython 3.10 macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
ab1a960cdbe4c5fecbd1bac6f6bf619b37186525c30ca0f14c73f561eb07dde0
|
|
BLAKE2b-256 checksum How to use checksums |
48fb7373fdccd6742837619640355960b8b5018879d1680d411a5986c2b8070d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / pyminiply-0.2.3-cp39-cp39-win_amd64.whl
| Download URL | pyminiply-0.2.3-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 59.8 kB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
75c2c926c90e01f20e995ebb35eeee6959f1a3ac51ec7b580846316b615ec87c
|
|
BLAKE2b-256 checksum How to use checksums |
c152c1caa7c57fd4d5237e8405eddba54ff752b6a34c0f68fddcc28d75246f32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / pyminiply-0.2.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyminiply-0.2.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 85.5 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
f005424986a75d317610155388eee58d24de9f5e3e9e118c5cf27abb0cc45e1a
|
|
BLAKE2b-256 checksum How to use checksums |
0baee71eb8783035a0389c45d782485866ac9adf42325cd8239ff79f8b7361d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / pyminiply-0.2.3-cp39-cp39-macosx_11_0_arm64.whl
| Download URL | pyminiply-0.2.3-cp39-cp39-macosx_11_0_arm64.whl |
|---|---|
| Size | 58.0 kB |
| Tags | CPython 3.9 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
46324a9a0b9347cae9441bb473a21f9112e1d03dee5bcc19fd4af90f383d170b
|
|
BLAKE2b-256 checksum How to use checksums |
0d6baf4300773b20de1eff177b99a6e0037961a39caaf4d25fe90a680e07a7e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / pyminiply-0.2.3-cp39-cp39-macosx_10_14_x86_64.whl
| Download URL | pyminiply-0.2.3-cp39-cp39-macosx_10_14_x86_64.whl |
|---|---|
| Size | 63.8 kB |
| Tags | CPython 3.9 macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
56762cc61e58ad081638977ded3ab3bf614a70a5729a704205d945bd013573c0
|
|
BLAKE2b-256 checksum How to use checksums |
36987cfb62018cfb8b11f9eb41ab1b7a659d4c2d7cf84dbf4c7809146fb00212
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|