Instance attributes vs method arguments
George Sakkis
george.sakkis at gmail.com
Tue Nov 25 21:34:54 EST 2008
On Nov 25, 8:49 pm, John O'Hagan <m... at johnohagan.com> wrote:
> is there an
> difference in efficiency (for large enough number of methods and arguments)
> between
>
> a) passing all arguments to __init__() and accessing them via self within
> individual methods:
>
> class = Class(all_class_args)
> class.method_a()
> class.method_b()
> ...
> or
>
> b) passing the arguments needed by each method when it is called on an
> instance:
>
> class = Class()
> class.method_a(a_args)
> class.method_b(b_args)
> ...
The difference in API here is more crucial than the difference in
performance. Deciding between the two based on the (guessed or
measured) performance improvement misses the point of OO design.
George
More information about the Python-list
mailing list