Comments (5)
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.
from pycraft.
The change_sector function could also benefit from being matrix addition.
https://github.com/traverseda/pycraft/blob/master/pycraft/world.py#L302
from pycraft.
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:
https://github.com/TristanTrim/pycraft/blob/numpy_cube_vertices/pycraft/util.py
Original cube_vertices function:
Average time for moving a cube is 3.7735462188720705e-06 over 10000 tests
Numpy re-implementation:
Average time for moving a cube is 1.2723827362060548e-05 over 10000 tests
Numpy re-implementation without (necessary) array.reshape call:
Average time for moving a cube is 8.726072311401368e-06 over 10000 tests
from pycraft.
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.
from pycraft.
if it was refactored to take a list of blocks in a region and return the list of vertices for each block
Yeah, this sound's good. I'm attempting it now, with some other refactoring.
from pycraft.
Related Issues (20)
- Make textures clearly belong to blocks HOT 3
- Seperate "world" and "window" HOT 1
- util.normalize() is rounding? HOT 9
- Define a structure for Game States HOT 1
- Current queue is stupid.
- Destroying hidden blocks causes keyerror.
- normalize HOT 1
- Basic Work? (Finding new textures) HOT 14
- test_licences failing HOT 4
- Decoupling view and world logic. HOT 2
- Fog doesn't work on Mac HOT 1
- Placing WeakStone causes KeyError
- Right click places two blocks HOT 5
- What are the Intended Target platforms for pycraft? HOT 3
- The 'pip install -e .' command doesn't work HOT 12
- Crash and error HOT 2
- HUGE terrain gen improvement HOT 2
- Depend on redis? (if you use a non-unix platform, please give this a read) HOT 7
- Better installation instructions for readme
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pycraft.