G
Guest
I would like to optimize my classes at run time. The question
is where to put my "if" statement.
-Inside __main__?
if option:
class Foo:
def __init__:
#do stuff
else:
class Foo:
def __init__:
#do other stuff
-Inside class definition?
class Foo:
if option:
def __init__:
#do stuff
else:
def __init__:
#do other stuff
-Inside each method definition?
class Foo:
def __init__:
if option:
#do stuff
else:
#do other stuff
Class instances will be created millions of times and the
method's on them called even more so whatever brings the most
speed will be used. I fear that the more readable way to do it
is also the slowest.
Thanks in advance,
-Brian
is where to put my "if" statement.
-Inside __main__?
if option:
class Foo:
def __init__:
#do stuff
else:
class Foo:
def __init__:
#do other stuff
-Inside class definition?
class Foo:
if option:
def __init__:
#do stuff
else:
def __init__:
#do other stuff
-Inside each method definition?
class Foo:
def __init__:
if option:
#do stuff
else:
#do other stuff
Class instances will be created millions of times and the
method's on them called even more so whatever brings the most
speed will be used. I fear that the more readable way to do it
is also the slowest.
Thanks in advance,
-Brian