Mercurial > cpython-lru_cache-weakref
annotate Include/floatobject.h @ 19283:b865cd5c1925 legacy-trunk
Added comments before recently added/assigned slots in the type object,
so the backward compatibility issues will be easier to understand. I only
added comments indicating additions and assignments back to Python 2.0.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Wed, 15 Aug 2001 18:32:33 +0000 |
| parents | fe4c1034b480 |
| children | 19d271f297dc |
| rev | line source |
|---|---|
| 145 | 1 |
| 6 | 2 /* Float object interface */ |
| 3 | |
| 4 /* | |
|
2129
05360cd616ae
The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents:
2058
diff
changeset
|
5 PyFloatObject represents a (double precision) floating point number. |
| 6 | 6 */ |
| 7 | |
|
13444
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
8 #ifndef Py_FLOATOBJECT_H |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
9 #define Py_FLOATOBJECT_H |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
10 #ifdef __cplusplus |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
11 extern "C" { |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
12 #endif |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
13 |
| 6 | 14 typedef struct { |
|
13444
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
15 PyObject_HEAD |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
16 double ob_fval; |
|
2129
05360cd616ae
The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents:
2058
diff
changeset
|
17 } PyFloatObject; |
| 6 | 18 |
|
2436
fa98dda07877
make the type a parameter of the DL_IMPORT macro, for Borland C
Guido van Rossum <guido@python.org>
parents:
2129
diff
changeset
|
19 extern DL_IMPORT(PyTypeObject) PyFloat_Type; |
| 6 | 20 |
|
2129
05360cd616ae
The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents:
2058
diff
changeset
|
21 #define PyFloat_Check(op) ((op)->ob_type == &PyFloat_Type) |
| 6 | 22 |
|
17707
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
23 /* Return Python float from string PyObject. Second argument ignored on |
|
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
24 input, and, if non-NULL, NULL is stored into *junk (this tried to serve a |
|
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
25 purpose once but can't be made to work as intended). */ |
|
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
26 extern DL_IMPORT(PyObject *) PyFloat_FromString(PyObject*, char** junk); |
|
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
27 |
|
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
28 /* Return Python float from C double. */ |
|
13444
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
29 extern DL_IMPORT(PyObject *) PyFloat_FromDouble(double); |
|
17707
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
30 |
|
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
31 /* Extract C double from Python float. The macro version trades safety for |
|
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
32 speed. */ |
|
13444
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
33 extern DL_IMPORT(double) PyFloat_AsDouble(PyObject *); |
|
17707
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
34 #define PyFloat_AS_DOUBLE(op) (((PyFloatObject *)(op))->ob_fval) |
| 6 | 35 |
|
17707
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
36 /* Write repr(v) into the char buffer argument, followed by null byte. The |
|
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
37 buffer must be "big enough"; >= 100 is very safe. |
|
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
38 PyFloat_AsReprString(buf, x) strives to print enough digits so that |
|
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
39 PyFloat_FromString(buf) then reproduces x exactly. */ |
|
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
40 extern DL_IMPORT(void) PyFloat_AsReprString(char*, PyFloatObject *v); |
|
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
41 |
|
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
42 /* Write str(v) into the char buffer argument, followed by null byte. The |
|
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
43 buffer must be "big enough"; >= 100 is very safe. Note that it's |
|
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
44 unusual to be able to get back the float you started with from |
|
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
45 PyFloat_AsString's result -- use PyFloat_AsReprString() if you want to |
|
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
46 preserve precision across conversions. */ |
|
fe4c1034b480
SF bug #422177: Results from .pyc differs from .py
Tim Peters <tim.peters@gmail.com>
parents:
14375
diff
changeset
|
47 extern DL_IMPORT(void) PyFloat_AsString(char*, PyFloatObject *v); |
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
48 |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
49 #ifdef __cplusplus |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
50 } |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
51 #endif |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
52 #endif /* !Py_FLOATOBJECT_H */ |
