Author |
Message |
do_pete
|
Posted: Fri Sep 15, 2006 9:30 am Post subject: Trig calculations vs. lookup tables |
|
|
I'm planning on making a game in Python that includes lots of trigonometry. Should I invest in making lookup tables to increase the speed or would that not make a difference? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
[Gandalf]
|
Posted: Fri Sep 15, 2006 2:20 pm Post subject: (No subject) |
|
|
I'm sure it would make at least a bit of a difference, though it really matters on how important speed and smooth execution will be in your game. In any case, I don't see why you shouldn't use them.. |
|
|
|
|
|
Cervantes
|
Posted: Fri Sep 15, 2006 2:44 pm Post subject: (No subject) |
|
|
[Gandalf] wrote: In any case, I don't see why you shouldn't use them..
Because they use up memory. If you're already using lots, you should be careful about its use. If you want to be precise in the values you get, you'll have to use lots of memory to store that accuracy. |
|
|
|
|
|
bugzpodder
|
Posted: Fri Sep 15, 2006 5:47 pm Post subject: (No subject) |
|
|
if you are worried about speed, then you shouldnt be using python. |
|
|
|
|
|
[Gandalf]
|
Posted: Fri Sep 15, 2006 6:01 pm Post subject: (No subject) |
|
|
Cervantes, true that. Though really, in most cases 1 degree accuracy won't take up a huge amount of memory and still does the job.
About speed... As far as I know Python seems like one of the better choices with regards to speed while still being beginner friendly.
Ignoring O'Caml, that is. ;) |
|
|
|
|
|
zylum
|
Posted: Fri Sep 15, 2006 6:46 pm Post subject: (No subject) |
|
|
isnt java faster than python? either way, unless you are doing thousands of trig calculations per loop, it shouldnt slow down your program too much. do some benchmarks. |
|
|
|
|
|
bugzpodder
|
Posted: Sat Sep 16, 2006 1:12 pm Post subject: (No subject) |
|
|
python is an interpreted language. C/C++ is compiled into bytecode. Java sort of sits in a middle but its VM are optimized enough so that you won't see too much of a performance loss compared to C/C++ (although it is still present). You may want to try out IronPython on the other hand since it works the same way as all other .net languages by compiling to IL. |
|
|
|
|
|
wtd
|
Posted: Sat Sep 16, 2006 1:16 pm Post subject: (No subject) |
|
|
C and C++ (and many other languages) are compiled into native machine code.
Java and Python are compiled to bytecode which is interpreted. Or alternatively, the interpreting environment may Just-in-Time compile this bytecode to native machine code. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
bugzpodder
|
Posted: Sat Sep 16, 2006 5:50 pm Post subject: (No subject) |
|
|
right, thats what i meant |
|
|
|
|
|
do_pete
|
Posted: Tue Sep 19, 2006 9:33 am Post subject: (No subject) |
|
|
Okay, thanks for the help. If I need more speed for my program is it possible to integrate C/C++ programs into it? |
|
|
|
|
|
zylum
|
Posted: Tue Sep 19, 2006 10:44 pm Post subject: (No subject) |
|
|
what exactly are you making that needs to that fast? |
|
|
|
|
|
bugzpodder
|
Posted: Wed Sep 20, 2006 6:57 am Post subject: (No subject) |
|
|
Sure, use IronPython |
|
|
|
|
|
do_pete
|
Posted: Wed Sep 20, 2006 8:35 am Post subject: (No subject) |
|
|
zylum wrote: what exactly are you making that needs to that fast? I'm planning on making a 2d version of Battlefield 2. |
|
|
|
|
|
bugzpodder
|
Posted: Wed Sep 20, 2006 9:14 am Post subject: (No subject) |
|
|
or look into python C API. although its more for C++ programmers to have access to python, rather than other way around |
|
|
|
|
|
wtd
|
Posted: Wed Sep 20, 2006 10:45 am Post subject: (No subject) |
|
|
I would mention that Ruby is considered to have one of the simplest C interfaces available. With it you can wrap C code so that it can be called from Ruby just as you would call any other Ruby code. |
|
|
|
|
|
|