python-sfml
python-sfml copied to clipboard
Fused type or not
I don't know what the best code to use is.
I have a function which can take either a Position or a Size. What piece of code should I write ?
What's the impact on performances ?
def function(object pos_size):
if type(pos_size) is Position:
cfunction((<Position>pos_size).thisptr)
else:
cfunction((<Size>pos_size).thisptr)
OR
ctypedef fused pos_or_size:
Position
Size
def function(pos_or_size foo)
if pos_or_size is Position:
cfunction((<Position>foo).thisptr)
else:
cfunction((<Size>foo).thisptr)