What is the difference between math.ceil(x) and x.__ceil__()?
It's almost the same. The only difference is that you can redefine the function with magic method (__ceil__()). I think there's no point in redefining math.ceil() so don't use __ceil__(). https://code.sololearn.com/ch7rUkvBxKG6/?ref=app edit: In Python float is primitive type, not a class. You can't redifine math.ceil(float). My example is creating a new float-like object, not changing the function with a float parameter.