Title: Slow performance on python wrapper · Issue #275 · tinyobjloader/tinyobjloader · GitHub
Open Graph Title: Slow performance on python wrapper · Issue #275 · tinyobjloader/tinyobjloader
X Title: Slow performance on python wrapper · Issue #275 · tinyobjloader/tinyobjloader
Description: Let's start by considering this snippet: import time from pathlib import Path import tinyobjloader def load_obj(filename): path = Path(filename).resolve() start = time.time() reader = tinyobjloader.ObjReader() if not reader.ParseFromFile...
Open Graph Description: Let's start by considering this snippet: import time from pathlib import Path import tinyobjloader def load_obj(filename): path = Path(filename).resolve() start = time.time() reader = tinyobjloader...
X Description: Let's start by considering this snippet: import time from pathlib import Path import tinyobjloader def load_obj(filename): path = Path(filename).resolve() start = time.time() reader = tinyobjlo...
Opengraph URL: https://github.com/tinyobjloader/tinyobjloader/issues/275
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Slow performance on python wrapper","articleBody":"Let's start by considering this snippet:\r\n\r\n import time\r\n from pathlib import Path\r\n\r\n import tinyobjloader\r\n\r\n\r\n def load_obj(filename):\r\n path = Path(filename).resolve()\r\n start = time.time()\r\n reader = tinyobjloader.ObjReader()\r\n if not reader.ParseFromFile(str(path)):\r\n raise Exception(f\"Problem loading '{path}'\")\r\n attrib = reader.GetAttrib()\r\n start = time.time()\r\n num_vertices = 0\r\n num_normals = 0\r\n num_texcoords = 0\r\n\r\n for shape in reader.GetShapes():\r\n num_vertices += len(attrib.vertices)\r\n num_normals += len(attrib.normals)\r\n num_texcoords += len(attrib.texcoords)\r\n\r\n for f in shape.mesh.indices:\r\n attrib.vertices[f.vertex_index * 3 + 0]\r\n attrib.vertices[f.vertex_index * 3 + 1]\r\n attrib.vertices[f.vertex_index * 3 + 2]\r\n attrib.normals[f.normal_index * 3 + 0]\r\n attrib.normals[f.normal_index * 3 + 1]\r\n attrib.normals[f.normal_index * 3 + 2]\r\n attrib.texcoords[f.texcoord_index * 2 + 0]\r\n attrib.texcoords[f.texcoord_index * 2 + 1]\r\n\r\n print(\r\n f\"num_vertices={num_vertices} num_normals={num_normals} num_texcoords={num_texcoords}\"\r\n )\r\n print(time.time() - start)\r\n\r\n\r\n if __name__ == \"__main__\":\r\n load_obj(r\"mcve.obj\")\r\n\r\nAnd here's the link to both [mcve.obj](https://www.dropbox.com/s/vslkrmgcczem7bh/mcve.obj?dl=0) and [mcve.mtl](https://www.dropbox.com/s/46rhn31wngtub5y/mcve.mtl?dl=1), this object is a very small \u0026 trivial scene, that looks like this:\r\n\r\n\r\n\r\nProblem being... if you run that snippet you'll get this output:\r\n\r\n num_vertices=36150 num_normals=38400 num_texcoords=27950\r\n 13.565775871276855\r\n\r\nThat's really slow \u0026 unusable for such a trivial scene. I wanted to san miguel's scene from [https://casual-effects.com/data/](https://casual-effects.com/data/) but after seeing these poor results on such a trivial scene I'm not even considering it till I figure out how to proceed here.\r\n\r\nSo yeah, the main question would be, how could we use the tinyobjloader effectively on python so we can test real-world scenes?\r\n\r\nThanks in advance.\r\n\r\nPs. I've got allocated a huge chunk of memory for interleaved data (vertices+normals+texcoords) so I'm not sure how difficult would be providing a wrapper to make a fast memcpy or similar... Main problem seems to be the whole overhead of wrapping c++ to python","author":{"url":"https://github.com/brupelo","@type":"Person","name":"brupelo"},"datePublished":"2020-05-26T17:50:08.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/275/tinyobjloader/issues/275"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8614c0fe-c645-d175-80f3-09054ace0188 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 87FC:36D01B:25F9808:355059D:6970FA9D |
| html-safe-nonce | f6851f16ddc388771286cb64451d7281b91c5401953802515e9d71c9c99abcf2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4N0ZDOjM2RDAxQjoyNUY5ODA4OjM1NTA1OUQ6Njk3MEZBOUQiLCJ2aXNpdG9yX2lkIjoiOTE2NDI3ODY4NzQwNDcxODc0OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 997393fb3a102beb7920d7ea1aed8f7a596d7067fe2ef3f6d1f82deb0832b9d3 |
| hovercard-subject-tag | issue:625069107 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/tinyobjloader/tinyobjloader/275/issue_layout |
| twitter:image | https://opengraph.githubassets.com/69b5b29c0652cf8e29e3605ec0de60fe674c35147b4efb0dd88af4c0d482ad9e/tinyobjloader/tinyobjloader/issues/275 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/69b5b29c0652cf8e29e3605ec0de60fe674c35147b4efb0dd88af4c0d482ad9e/tinyobjloader/tinyobjloader/issues/275 |
| og:image:alt | Let's start by considering this snippet: import time from pathlib import Path import tinyobjloader def load_obj(filename): path = Path(filename).resolve() start = time.time() reader = tinyobjloader... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | brupelo |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2d17fd2bbd784dc91f3a78a2f1d2c41d9f4f8ce86136d09833e3cf21b2bde1b7 |
| turbo-cache-control | no-preview |
| go-import | github.com/tinyobjloader/tinyobjloader git https://github.com/tinyobjloader/tinyobjloader.git |
| octolytics-dimension-user_id | 61176939 |
| octolytics-dimension-user_login | tinyobjloader |
| octolytics-dimension-repository_id | 5421296 |
| octolytics-dimension-repository_nwo | tinyobjloader/tinyobjloader |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 5421296 |
| octolytics-dimension-repository_network_root_nwo | tinyobjloader/tinyobjloader |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e053d923fb27a9d948f8cefae8ba3bf43f7b938f |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width