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