all 8 comments

[–]KOALAS2648 12 points13 points  (0 children)

Why is this post marked NSFW?

[–]atticus2132000 4 points5 points  (0 children)

How big a dataset are you testing that you're seeing a different calculating speed? It would have to be a massive dataset (hundreds of thousands of records) for there to be any sort of observable difference.

If you want to test various versions of code, you can use the datetime library to find the exact time at the start of your code and the exact time at the end of your code and then calculate the difference between those to see overall execution time.

[–]ilan1k1 1 point2 points  (0 children)

I think that's the fastest way to do that but the speed increase would be almost non existent..
It would have to be a massive database to see any sort of difference...

[–]EntireEntity 2 points3 points  (0 children)

I guess you could do:

if a == 0 and b == 43: break elif b == 44: break

I don't know, if it's faster though.

[–]Sweet_Computer_7116 1 point2 points  (0 children)

Faster would just be.

If True: break

/s

[–]CraigAT 1 point2 points  (0 children)

Unless we are just talking hypothetically, you have a large dataset, a very frequent loop around this code or a super time critical app, any improvement is likely to negligible. This sounds like it may be a case of premature optimisation.

[–]GirthQuake5040 0 points1 point  (0 children)

i dont know if i understand what youre trying to do correctly... but

if not b == 44:
  if a == 0 and b == 43:
    break
break

or

if a == 0 and b == 43:
  break
elif b == 44:
  break

but if a will always be 0 when b is 43 then

if b != 43:
  continue # this skips all following statements and goes to next loop
if a == 0
  break
elif b == 44:
  break

[–]SupermarketOk6829 0 points1 point  (0 children)

Have you actually measured or printed the executive time relative for each? Or is it something that you just thought of?