python - 如何在 Python 中使用带有 ctypes.Strcuture 类的插槽?
问题描述
我正在使用 Python 2.7 编写一个应用程序,它将大量 3D 网格结构从一个应用程序导出到另一个应用程序。
由于大量 3D 数据,我定义了一个名为“Face”的类,如下代码所示,作为传递给 c-dll 的临时数据结构。
我的问题:如果我想用插槽保存内存,我该如何重新定义这个类?或者有没有其他方法可以有效地节省内存?
class Face(ctypes.Structure):
__slots__ = ()
# __slots__ = ['A','B','C','vert_index','vert_index','edge_sm','sm_group','is_hidden','edge_hidden','mtl_index','uv']
_fields_ = [
("A", ctypes.POINTER(ctypes.c_double)),
("B", ctypes.POINTER(ctypes.c_double)),
("C", ctypes.POINTER(ctypes.c_double)),
("vert_index", ctypes.POINTER(ctypes.c_int)),
("edge_sm", ctypes.POINTER(ctypes.c_bool)),
("sm_group", ctypes.c_int),
("is_hidden", ctypes.c_bool),
("edge_hidden", ctypes.POINTER(ctypes.c_int)),
("mtl_index", ctypes.c_int),
("uv", ctypes.POINTER(ctypes.c_double)),
]
感谢任何建议。谢谢。
解决方案
推荐阅读
- ethereum - 即使帐户存在,也无法使用 geth 控制台列出帐户
- php - 在 get 中添加 application/json 标头返回错误 500?
- python - PyCharm - matlabengineforpython3_7
- automation - 如何通过多台机器在 bitbucket 中运行并行测试?
- sqlite - 在循环 SQLite 中引用过去的查询
- spring-boot - CrudRepository 返回错误的结果集
- ruby-on-rails - 验证 Rails 5 中至少勾选了一个复选框
- javascript - 访问者离线时如何触发 Bootstrap Toasts?
- postgresql - CSV 中引用的雪花空值会破坏 PostgreSQL 卸载
- ios - 单击提交以供审核时的 AppStore 仪表板