annotate Include/complexobject.h @ 87690:66c1c9f32567 default tip

Add use_weakref option to functools.lru_cache The use_weakref option makes lru_cache create weak references to the function arguments when creating the cache key, which prevents them from staying in the memory forever even after all other references to them are gone. This is a proof of concept for http://bugs.python.org/issue19859
author Radomir Dopieralski <devel@sheep.art.pl>
date Tue, 03 Dec 2013 16:02:48 +0100
parents 22b56b0b8619
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 9586
diff changeset
1 /* Complex number structure */
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 9586
diff changeset
2
25554
36124157b317 SF # 607253, header file problems by Ralf W. Grosse-Kunstleve
Neal Norwitz <nnorwitz@gmail.com>
parents: 24752
diff changeset
3 #ifndef Py_COMPLEXOBJECT_H
36124157b317 SF # 607253, header file problems by Ralf W. Grosse-Kunstleve
Neal Norwitz <nnorwitz@gmail.com>
parents: 24752
diff changeset
4 #define Py_COMPLEXOBJECT_H
3316
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 #ifdef __cplusplus
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 extern "C" {
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 #endif
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
8
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 53632
diff changeset
9 #ifndef Py_LIMITED_API
3316
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 typedef struct {
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 9586
diff changeset
11 double real;
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 9586
diff changeset
12 double imag;
3765
db5488fe495b renamed complex -> Py_complex
Guido van Rossum <guido@python.org>
parents: 3613
diff changeset
13 } Py_complex;
3316
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
14
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 /* Operations on complex numbers from complexmodule.c */
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
16
3613
2f314ca0cd33 rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents: 3321
diff changeset
17 #define c_sum _Py_c_sum
2f314ca0cd33 rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents: 3321
diff changeset
18 #define c_diff _Py_c_diff
2f314ca0cd33 rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents: 3321
diff changeset
19 #define c_neg _Py_c_neg
2f314ca0cd33 rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents: 3321
diff changeset
20 #define c_prod _Py_c_prod
2f314ca0cd33 rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents: 3321
diff changeset
21 #define c_quot _Py_c_quot
2f314ca0cd33 rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents: 3321
diff changeset
22 #define c_pow _Py_c_pow
46477
b69f443ef480 Merged revisions 62380,62382-62383 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
23 #define c_abs _Py_c_abs
3613
2f314ca0cd33 rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents: 3321
diff changeset
24
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 19889
diff changeset
25 PyAPI_FUNC(Py_complex) c_sum(Py_complex, Py_complex);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 19889
diff changeset
26 PyAPI_FUNC(Py_complex) c_diff(Py_complex, Py_complex);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 19889
diff changeset
27 PyAPI_FUNC(Py_complex) c_neg(Py_complex);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 19889
diff changeset
28 PyAPI_FUNC(Py_complex) c_prod(Py_complex, Py_complex);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 19889
diff changeset
29 PyAPI_FUNC(Py_complex) c_quot(Py_complex, Py_complex);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 19889
diff changeset
30 PyAPI_FUNC(Py_complex) c_pow(Py_complex, Py_complex);
46477
b69f443ef480 Merged revisions 62380,62382-62383 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44351
diff changeset
31 PyAPI_FUNC(double) c_abs(Py_complex);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 53632
diff changeset
32 #endif
3316
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
33
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 /* Complex object interface */
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
35
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 /*
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
37 PyComplexObject represents a complex number with double-precision
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 real and imaginary parts.
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 */
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 53632
diff changeset
40 #ifndef Py_LIMITED_API
3316
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
41 typedef struct {
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 9586
diff changeset
42 PyObject_HEAD
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 9586
diff changeset
43 Py_complex cval;
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 53632
diff changeset
44 } PyComplexObject;
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 53632
diff changeset
45 #endif
3316
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
46
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 19889
diff changeset
47 PyAPI_DATA(PyTypeObject) PyComplex_Type;
3316
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
48
19550
19d271f297dc Make the PyXXX_Check() macros for the numeric types inheritance-aware.
Guido van Rossum <guido@python.org>
parents: 13444
diff changeset
49 #define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 42334
diff changeset
50 #define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type)
3316
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
51
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 53632
diff changeset
52 #ifndef Py_LIMITED_API
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 19889
diff changeset
53 PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 53632
diff changeset
54 #endif
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 19889
diff changeset
55 PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);
3316
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
56
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 19889
diff changeset
57 PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 19889
diff changeset
58 PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 53632
diff changeset
59 #ifndef Py_LIMITED_API
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 19889
diff changeset
60 PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 53632
diff changeset
61 #endif
3316
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
62
53632
2cde0d003ffc Issue #1588: Add complex.__format__.
Eric Smith <eric@trueblade.com>
parents: 46477
diff changeset
63 /* Format the object based on the format_spec, as defined in PEP 3101
2cde0d003ffc Issue #1588: Add complex.__format__.
Eric Smith <eric@trueblade.com>
parents: 46477
diff changeset
64 (Advanced String Formatting). */
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 53632
diff changeset
65 #ifndef Py_LIMITED_API
77223
22b56b0b8619 Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args)
Victor Stinner <victor.stinner@gmail.com>
parents: 72475
diff changeset
66 PyAPI_FUNC(int) _PyComplex_FormatAdvancedWriter(
22b56b0b8619 Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args)
Victor Stinner <victor.stinner@gmail.com>
parents: 72475
diff changeset
67 _PyUnicodeWriter *writer,
22b56b0b8619 Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args)
Victor Stinner <victor.stinner@gmail.com>
parents: 72475
diff changeset
68 PyObject *obj,
22b56b0b8619 Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args)
Victor Stinner <victor.stinner@gmail.com>
parents: 72475
diff changeset
69 PyObject *format_spec,
22b56b0b8619 Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args)
Victor Stinner <victor.stinner@gmail.com>
parents: 72475
diff changeset
70 Py_ssize_t start,
22b56b0b8619 Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args)
Victor Stinner <victor.stinner@gmail.com>
parents: 72475
diff changeset
71 Py_ssize_t end);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 53632
diff changeset
72 #endif
53632
2cde0d003ffc Issue #1588: Add complex.__format__.
Eric Smith <eric@trueblade.com>
parents: 46477
diff changeset
73
3316
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
74 #ifdef __cplusplus
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
75 }
e5d1f242daf9 complex numbers a la Konrad Hinsen
Guido van Rossum <guido@python.org>
parents:
diff changeset
76 #endif
25554
36124157b317 SF # 607253, header file problems by Ralf W. Grosse-Kunstleve
Neal Norwitz <nnorwitz@gmail.com>
parents: 24752
diff changeset
77 #endif /* !Py_COMPLEXOBJECT_H */