@@ -684,46 +684,58 @@ complex_float(PyObject *v)
684
684
return NULL ;
685
685
}
686
686
687
+ /*[clinic input]
688
+ complex.conjugate
689
+
690
+ complex.conjugate() -> complex
691
+
692
+ Return the complex conjugate of its argument. (3-4j).conjugate() == 3+4j.
693
+ [clinic start generated code]*/
694
+
687
695
static PyObject *
688
- complex_conjugate (PyObject * self , PyObject * Py_UNUSED (ignored ))
696
+ complex_conjugate_impl (PyComplexObject * self )
697
+ /*[clinic end generated code: output=5059ef162edfc68e input=1d8257f99c298f70]*/
689
698
{
690
- Py_complex c ;
691
- c = ((PyComplexObject * )self )-> cval ;
699
+ Py_complex c = self -> cval ;
692
700
c .imag = - c .imag ;
693
701
return PyComplex_FromCComplex (c );
694
702
}
695
703
696
- PyDoc_STRVAR ( complex_conjugate_doc ,
697
- " complex.conjugate() -> complex\n"
698
- "\n"
699
- "Return the complex conjugate of its argument. (3-4j).conjugate() == 3+4j." );
704
+ /*[clinic input]
705
+ complex.__getnewargs__
706
+
707
+ [clinic start generated code]*/
700
708
701
709
static PyObject *
702
- complex_getnewargs (PyComplexObject * v , PyObject * Py_UNUSED (ignored ))
710
+ complex___getnewargs___impl (PyComplexObject * self )
711
+ /*[clinic end generated code: output=689b8206e8728934 input=539543e0a50533d7]*/
703
712
{
704
- Py_complex c = v -> cval ;
713
+ Py_complex c = self -> cval ;
705
714
return Py_BuildValue ("(dd)" , c .real , c .imag );
706
715
}
707
716
708
- PyDoc_STRVAR (complex__format__doc ,
709
- "complex.__format__() -> str\n"
710
- "\n"
711
- "Convert to a string according to format_spec." );
717
+
718
+ /*[clinic input]
719
+ complex.__format__
720
+
721
+ format_spec: unicode
722
+ /
723
+
724
+ complex.__format__() -> str
725
+
726
+ Convert to a string according to format_spec.
727
+ [clinic start generated code]*/
712
728
713
729
static PyObject *
714
- complex__format__ (PyObject * self , PyObject * args )
730
+ complex___format___impl (PyComplexObject * self , PyObject * format_spec )
731
+ /*[clinic end generated code: output=bfcb60df24cafea0 input=b62fc6fbc2ec61a5]*/
715
732
{
716
- PyObject * format_spec ;
717
733
_PyUnicodeWriter writer ;
718
734
int ret ;
719
-
720
- if (!PyArg_ParseTuple (args , "U:__format__" , & format_spec ))
721
- return NULL ;
722
-
723
735
_PyUnicodeWriter_Init (& writer );
724
736
ret = _PyComplex_FormatAdvancedWriter (
725
737
& writer ,
726
- self ,
738
+ ( PyObject * ) self ,
727
739
format_spec , 0 , PyUnicode_GET_LENGTH (format_spec ));
728
740
if (ret == -1 ) {
729
741
_PyUnicodeWriter_Dealloc (& writer );
@@ -733,11 +745,9 @@ complex__format__(PyObject* self, PyObject* args)
733
745
}
734
746
735
747
static PyMethodDef complex_methods [] = {
736
- {"conjugate" , (PyCFunction )complex_conjugate , METH_NOARGS ,
737
- complex_conjugate_doc },
738
- {"__getnewargs__" , (PyCFunction )complex_getnewargs , METH_NOARGS },
739
- {"__format__" , (PyCFunction )complex__format__ ,
740
- METH_VARARGS , complex__format__doc },
748
+ COMPLEX_CONJUGATE_METHODDEF
749
+ COMPLEX___GETNEWARGS___METHODDEF
750
+ COMPLEX___FORMAT___METHODDEF
741
751
{NULL , NULL } /* sentinel */
742
752
};
743
753
0 commit comments