#π improve codes computational efficiency
34 messages Β· Page 1 of 1 (latest)
@craggy hare
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.
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
is it actively causing issues?
or have you measuered how long it takes to execute?
- Time taken to process directory: 0.10703 seconds
- Time taken to process directory: 0.11595 seconds
- without the enumerating code snippet and 2. is with
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
i run this every second on thousands of images
that's why i am here. those few milliseconds, stack up alot
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
First, are you running on the same images? Is there an opportunity to cache?
already caching, wrote a class for that and also re-using the tesseract api object by using the tesserocr bindings for it, the ocr isn't the issue. the issue is the pre-processing
Have you profiled it?
Vectorizing the loop might help, but I wouldnβt bother unless my profile says so.
i went from enumerate to for loop lol
But does profiling say this dominates your runtime?
Which profiler do you use?
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
Alright, thanks
Like, if itβs all in one function, you want to break it up
I use Austin so i was wondering what you used
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