Re: [PyOpenGL-Users] Collision Detections
Brought to you by:
mcfletch
From: Richard J. <ric...@op...> - 2004-01-02 04:20:30
|
On Friday 02 January 2004 12:43, Yannick Gingras wrote: > On January 1, 2004 20:00, Richard Jones wrote: > > Note that any implementation using map() will incur a function call > > overhead, which is slow if you're not using a builtin function. Use a f= or > > loop instead > > Strange, I thought that the map() version was alway the more efficient > as long as the lambda form was not invloved... > > Sure I can kick most of my map()s to rewrite in-line. I like to > substract vectors like that: > > v1 =3D (0.0, 0.0,-0.5) > v2 =3D (1.0, 0.0, 0.5) > v3 =3D map(sub, v1, v2) Well, the performance of that approach depends a lot on what "sub" is. If i= t's=20 a function defined by you in Python, it's going to be as slow as a lambda=20 call. If it's a Python builtin function (say, operator.sub) then it'll be=20 very fast. Note that you may want to look into Numeric Python to perform array=20 operations, as they're generally much faster than even using operator.sub (= as=20 the former is highly optimised, whereas the latter is as general as it can= =20 be). > Thanks for the pointers. I never tried to subdivide my world into > sectors, I guess it's time. Subdividing and bounds-checking are definitely worth the effort before you = get=20 into code optimisation like we're talking about above :) Richard |