print statements and profiling a function slowed performance

Mark Lawrence breamoreboy at yahoo.co.uk
Thu Jun 26 15:27:48 EDT 2014


On 26/06/2014 19:44, CM wrote:
> Huh. I learned two new Python facts this week:
>
> 1. print statements were slowing down my code enough to
> really notice a particular transition. It went from about
> 2-3 seconds to a bit under 1 second. What at first seemed
> unresponsive now seems almost snappy. The only difference
> was removing a lot of print statements I had used for
> debugging (Python 2.5, on a single core 1.97 Ghz machine).
>
> 2. Merely having a cPython decorator for profiling a
> function significantly slowed down performance...again,
> from a about 2 seconds to just under a second (~1 second
> doesn't seem much but these sorts of delays do affect
> user experience).  There is something ironic or
> Heisenbergian about that.
>

3. use the logging module :)

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com





More information about the Python-list mailing list