square¶
- iteration_utilities.square(value, /)¶
Returns the squared value.
- Parameters:
- valueany type
The value to be squared. The type of the value must support
pow
.
- Returns:
- squareany type
Returns
value**2
.
Examples
It is not possible to apply
functools.partial()
topow()
so that one has a one-argument square function and is significantly faster thanlambda x: x**2
:>>> from iteration_utilities import square >>> square(1) 1 >>> square(2.0) 4.0