Python Forum
Help with speed up my subroutine
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with speed up my subroutine
#2
As former Zooniverse user you have peeked my interest. Unfortunately I have no numpy experience, so I'm not sure the following might help.

At your 3e and 4e inner loops your using compares like if first0<second0<fourth0 or first0>second0>fourth0:.

One could try to limit that to one compare by using pre-ordered-value variables. ie if low0<second0<high0: or of course if high0>second0<low0:.
This part only give a minor (potential trivial) speed gain, its the fact that you can test and preset those high0 & low0 variables before you enter the loop where you do those compares that makes this potential interesting to gain some speed.
With high0 and low0 being something like: low0=min(first0,fourth0) & high0=max(first0,fourth0)

I'm not sure how much speed gain this gives, probably not that significant. But if applied to all jobs than can be lifted from lower to higher loops, it still might add up.


PS: One other thing. You say
pberrett Wrote:.. 4 positions in a straight line travelling at a constant speed ..
Make sure your detection allows for some deviation, especially for images from ground based telescopes (atmosphere and such).
See for example 'New Candidates' case 2 in this asteroidzoo result.
Going beyond the idiomatic Python (Sensible Idiomatic usage - Blog post - Sep 11th 2017)
Reply


Messages In This Thread
Help with speed up my subroutine - by pberrett - May-12-2019, 06:36 AM
RE: Help with speed up my subroutine - by MvGulik - May-12-2019, 08:59 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020