-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regular rather than matrix addition #56
Comments
The change_sector function could also benefit from being matrix addition. |
I notice that I'm confused, but re-implementing cube_vertices in numpy made it slower. If anyone knows why this is, I'm pretty curious. Check it out on this branch if you curious: Original cube_vertices function: |
It seems to be because the costs of creating an array in numpy are a lot more then the costs of creating an array in plain python. |
NumPy is generally only faster than pure Python for operations on large arrays. I don't remember the exact switching point, but most of the benchmarks I've seen don't show benefits for NumPy arrays over Python lists until you have on the order of a few thousand array elements. I don't have a good sense of everywhere the cube_vertices() function is used in the code, but if it was refactored to take a list of blocks in a region and return the list of vertices for each block, rather than taking a single block, then a NumPy implementation might be faster. |
Yeah, this sound's good. I'm attempting it now, with some other refactoring. |
The cube_vertices function in pycraft/util.py is manually doing addition to every element in a list. I'm about 60% sure that this needs to be happening in numpy or pyglet to be a reasonable speed.
If this get's fixed, the blocks could be moved over .5 and normalize swapped to using floor as described in #45 . This may cascade into other logic though, idk.
The text was updated successfully, but these errors were encountered: