#πŸ”’ improve codes computational efficiency

34 messages Β· Page 1 of 1 (latest)

frail boneBOT
#

@craggy hare

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

craggy hare
#

but also just generally improve the efficiency of this function, I feel like the way I wrote these things, is very ineffective and ends up slowing down my code alot

sand glade
#

or have you measuered how long it takes to execute?

craggy hare
#
  1. without the enumerating code snippet and 2. is with
sand glade
#

yeah

#

i mean

#

as long as you arent building for the slowest of computers

#

or running this every second

#

it should be fine as is

craggy hare
#

i run this every second on thousands of images

sand glade
#

ooh

#

then that may be an issue

craggy hare
#

that's why i am here. those few milliseconds, stack up alot

sand glade
#

alright, i was just making sure

#

unfortunately I'm not good with this kind of thing, but have you asked general chat about it?

#

you can ask if there is anybody willing to help, then link to this thread

heavy wagon
#

First, are you running on the same images? Is there an opportunity to cache?

craggy hare
heavy wagon
#

Have you profiled it?

#

Vectorizing the loop might help, but I wouldn’t bother unless my profile says so.

craggy hare
#

i went from enumerate to for loop lol

heavy wagon
#

But does profiling say this dominates your runtime?

sand glade
heavy wagon
#

Cprofile then first tool is snakeviz or sometimes tuna

#

Line_profiler is helpful

#

It may help to move the suspicious code to a function for cprofile to pick it up

sand glade
#

Alright, thanks

heavy wagon
#

Like, if it’s all in one function, you want to break it up

sand glade
#

I use Austin so i was wondering what you used

frail boneBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.

#

πŸ”’ improve codes computational efficiency