[Tutor] How expensive is a function call

Alexandre Ratti alex@gabuzomeu.net
Fri, 24 May 2002 11:09:10 +0200


Hi Arthur,


At 04:09 24/05/2002 -0400, tutor-request@python.org wrote:
>From: "Arthur Siegel" <ajs@ix.netcom.com>
>Date: Thu, 23 May 2002 13:54:11 -0400
>Subject: [Tutor] How expensive is a function call

I am trying to focus on performance issues
>in this round of refractoring of something
>I have been working on.
>
>In a frequently called section of the code I need
>to check for bounds - are my coordinates so
>large that it will screw up the scene display.
>If so, scale.
>
>As I have it currently structured all the bounds checking
>is in a seperate function at the module top level, and it is
>automatically called within the  "update" function of
>a class  - as part of the recurring update processing.
>
>It would probably have been better to test for the
>bounds condition within the class update function
>itself rathering than exiting to a function that tests the
>bounds (and immediately returns if within bounds).
>
>My question then is how much am I losing by this?
>Is the call to the outside function that could to avoided
>in most cases expensive?
>
>In the helping people to help themselves - I have been
>intimidated from trying to tackle profiling of performance.
>Is anyone aware of a basic tutorial on this topic?