Commit 17f53ec1 authored by Stefan Behnel's avatar Stefan Behnel

enable two-value form of builtin pow()

parent 4d3030b3
......@@ -44,6 +44,7 @@ builtin_function_table = [
#('open', "ss", "O", "PyFile_FromString"),
#('ord', "", "", ""),
('pow', "OOO", "O", "PyNumber_Power"),
('pow', "OO", "O", "__Pyx_PyNumber_Power2"),
#('range', "", "", ""),
#('raw_input', "", "", ""),
#('reduce', "", "", ""),
......@@ -152,6 +153,11 @@ builtin_structs_table = [
])
]
pow2_utility_code = UtilityCode(
proto = """
#define __Pyx_PyNumber_Power2(a, b) PyNumber_Power(a, b, Py_None)
""")
getattr3_utility_code = UtilityCode(
proto = """
static PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *); /*proto*/
......@@ -383,6 +389,7 @@ Py_XDECREF(__Pyx_PyFrozenSet_Type); __Pyx_PyFrozenSet_Type = NULL;
builtin_utility_code = {
'exec' : pyexec_utility_code,
'getattr3' : getattr3_utility_code,
'pow' : pow2_utility_code,
'intern' : intern_utility_code,
'set' : py23_set_utility_code,
'frozenset' : py23_set_utility_code,
......
......@@ -15,6 +15,7 @@ cdef int f() except -1:
i = len(x)
x = open(y, z)
x = pow(y, z, w)
x = pow(y, z)
x = reload(y)
x = repr(y)
setattr(x, y, z)
......
def pow3(a,b,c):
"""
>>> pow3(2,3,5)
3
>>> pow3(3,3,5)
2
"""
return pow(a,b,c)
def pow3_const():
"""
>>> pow3_const()
3
"""
return pow(2,3,5)
def pow2(a,b):
"""
>>> pow2(2,3)
8
>>> pow2(3,3)
27
"""
return pow(a,b)
def pow2_const():
"""
>>> pow2_const()
8
"""
return pow(2,3)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment