Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

abstract.h 40 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
  1. /* Abstract Object Interface (many thanks to Jim Fulton) */
  2. #ifndef Py_ABSTRACTOBJECT_H
  3. #define Py_ABSTRACTOBJECT_H
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /* === Object Protocol ================================================== */
  8. /* Implemented elsewhere:
  9. int PyObject_Print(PyObject *o, FILE *fp, int flags);
  10. Print an object 'o' on file 'fp'. Returns -1 on error. The flags argument
  11. is used to enable certain printing options. The only option currently
  12. supported is Py_Print_RAW.
  13. (What should be said about Py_Print_RAW?). */
  14. /* Implemented elsewhere:
  15. int PyObject_HasAttrString(PyObject *o, const char *attr_name);
  16. Returns 1 if object 'o' has the attribute attr_name, and 0 otherwise.
  17. This is equivalent to the Python expression: hasattr(o,attr_name).
  18. This function always succeeds. */
  19. /* Implemented elsewhere:
  20. PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name);
  21. Retrieve an attributed named attr_name form object o.
  22. Returns the attribute value on success, or NULL on failure.
  23. This is the equivalent of the Python expression: o.attr_name. */
  24. /* Implemented elsewhere:
  25. int PyObject_HasAttr(PyObject *o, PyObject *attr_name);
  26. Returns 1 if o has the attribute attr_name, and 0 otherwise.
  27. This is equivalent to the Python expression: hasattr(o,attr_name).
  28. This function always succeeds. */
  29. /* Implemented elsewhere:
  30. PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name);
  31. Retrieve an attributed named 'attr_name' form object 'o'.
  32. Returns the attribute value on success, or NULL on failure.
  33. This is the equivalent of the Python expression: o.attr_name. */
  34. /* Implemented elsewhere:
  35. int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v);
  36. Set the value of the attribute named attr_name, for object 'o',
  37. to the value 'v'. Raise an exception and return -1 on failure; return 0 on
  38. success.
  39. This is the equivalent of the Python statement o.attr_name=v. */
  40. /* Implemented elsewhere:
  41. int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v);
  42. Set the value of the attribute named attr_name, for object 'o', to the value
  43. 'v'. an exception and return -1 on failure; return 0 on success.
  44. This is the equivalent of the Python statement o.attr_name=v. */
  45. /* Implemented as a macro:
  46. int PyObject_DelAttrString(PyObject *o, const char *attr_name);
  47. Delete attribute named attr_name, for object o. Returns
  48. -1 on failure.
  49. This is the equivalent of the Python statement: del o.attr_name. */
  50. #define PyObject_DelAttrString(O,A) PyObject_SetAttrString((O),(A), NULL)
  51. /* Implemented as a macro:
  52. int PyObject_DelAttr(PyObject *o, PyObject *attr_name);
  53. Delete attribute named attr_name, for object o. Returns -1
  54. on failure. This is the equivalent of the Python
  55. statement: del o.attr_name. */
  56. #define PyObject_DelAttr(O,A) PyObject_SetAttr((O),(A), NULL)
  57. /* Implemented elsewhere:
  58. PyObject *PyObject_Repr(PyObject *o);
  59. Compute the string representation of object 'o'. Returns the
  60. string representation on success, NULL on failure.
  61. This is the equivalent of the Python expression: repr(o).
  62. Called by the repr() built-in function. */
  63. /* Implemented elsewhere:
  64. PyObject *PyObject_Str(PyObject *o);
  65. Compute the string representation of object, o. Returns the
  66. string representation on success, NULL on failure.
  67. This is the equivalent of the Python expression: str(o).
  68. Called by the str() and print() built-in functions. */
  69. /* Declared elsewhere
  70. PyAPI_FUNC(int) PyCallable_Check(PyObject *o);
  71. Determine if the object, o, is callable. Return 1 if the object is callable
  72. and 0 otherwise.
  73. This function always succeeds. */
  74. #ifdef PY_SSIZE_T_CLEAN
  75. # define PyObject_CallFunction _PyObject_CallFunction_SizeT
  76. # define PyObject_CallMethod _PyObject_CallMethod_SizeT
  77. # ifndef Py_LIMITED_API
  78. # define _PyObject_CallMethodId _PyObject_CallMethodId_SizeT
  79. # endif /* !Py_LIMITED_API */
  80. #endif
  81. /* Call a callable Python object 'callable' with arguments given by the
  82. tuple 'args' and keywords arguments given by the dictionary 'kwargs'.
  83. 'args' must not be *NULL*, use an empty tuple if no arguments are
  84. needed. If no named arguments are needed, 'kwargs' can be NULL.
  85. This is the equivalent of the Python expression:
  86. callable(*args, **kwargs). */
  87. PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable,
  88. PyObject *args, PyObject *kwargs);
  89. #ifndef Py_LIMITED_API
  90. PyAPI_FUNC(PyObject*) _PyStack_AsTuple(
  91. PyObject *const *stack,
  92. Py_ssize_t nargs);
  93. PyAPI_FUNC(PyObject*) _PyStack_AsTupleSlice(
  94. PyObject *const *stack,
  95. Py_ssize_t nargs,
  96. Py_ssize_t start,
  97. Py_ssize_t end);
  98. /* Convert keyword arguments from the FASTCALL (stack: C array, kwnames: tuple)
  99. format to a Python dictionary ("kwargs" dict).
  100. The type of kwnames keys is not checked. The final function getting
  101. arguments is responsible to check if all keys are strings, for example using
  102. PyArg_ParseTupleAndKeywords() or PyArg_ValidateKeywordArguments().
  103. Duplicate keys are merged using the last value. If duplicate keys must raise
  104. an exception, the caller is responsible to implement an explicit keys on
  105. kwnames. */
  106. PyAPI_FUNC(PyObject *) _PyStack_AsDict(
  107. PyObject *const *values,
  108. PyObject *kwnames);
  109. /* Convert (args, nargs, kwargs: dict) into a (stack, nargs, kwnames: tuple).
  110. Return 0 on success, raise an exception and return -1 on error.
  111. Write the new stack into *p_stack. If *p_stack is differen than args, it
  112. must be released by PyMem_Free().
  113. The stack uses borrowed references.
  114. The type of keyword keys is not checked, these checks should be done
  115. later (ex: _PyArg_ParseStackAndKeywords). */
  116. PyAPI_FUNC(int) _PyStack_UnpackDict(
  117. PyObject *const *args,
  118. Py_ssize_t nargs,
  119. PyObject *kwargs,
  120. PyObject *const **p_stack,
  121. PyObject **p_kwnames);
  122. /* Suggested size (number of positional arguments) for arrays of PyObject*
  123. allocated on a C stack to avoid allocating memory on the heap memory. Such
  124. array is used to pass positional arguments to call functions of the
  125. _PyObject_FastCall() family.
  126. The size is chosen to not abuse the C stack and so limit the risk of stack
  127. overflow. The size is also chosen to allow using the small stack for most
  128. function calls of the Python standard library. On 64-bit CPU, it allocates
  129. 40 bytes on the stack. */
  130. #define _PY_FASTCALL_SMALL_STACK 5
  131. /* Return 1 if callable supports FASTCALL calling convention for positional
  132. arguments: see _PyObject_FastCallDict() and _PyObject_FastCallKeywords() */
  133. PyAPI_FUNC(int) _PyObject_HasFastCall(PyObject *callable);
  134. /* Call the callable object 'callable' with the "fast call" calling convention:
  135. args is a C array for positional arguments (nargs is the number of
  136. positional arguments), kwargs is a dictionary for keyword arguments.
  137. If nargs is equal to zero, args can be NULL. kwargs can be NULL.
  138. nargs must be greater or equal to zero.
  139. Return the result on success. Raise an exception on return NULL on
  140. error. */
  141. PyAPI_FUNC(PyObject *) _PyObject_FastCallDict(
  142. PyObject *callable,
  143. PyObject *const *args,
  144. Py_ssize_t nargs,
  145. PyObject *kwargs);
  146. /* Call the callable object 'callable' with the "fast call" calling convention:
  147. args is a C array for positional arguments followed by values of
  148. keyword arguments. Keys of keyword arguments are stored as a tuple
  149. of strings in kwnames. nargs is the number of positional parameters at
  150. the beginning of stack. The size of kwnames gives the number of keyword
  151. values in the stack after positional arguments.
  152. kwnames must only contains str strings, no subclass, and all keys must
  153. be unique.
  154. If nargs is equal to zero and there is no keyword argument (kwnames is
  155. NULL or its size is zero), args can be NULL.
  156. Return the result on success. Raise an exception and return NULL on
  157. error. */
  158. PyAPI_FUNC(PyObject *) _PyObject_FastCallKeywords(
  159. PyObject *callable,
  160. PyObject *const *args,
  161. Py_ssize_t nargs,
  162. PyObject *kwnames);
  163. #define _PyObject_FastCall(func, args, nargs) \
  164. _PyObject_FastCallDict((func), (args), (nargs), NULL)
  165. #define _PyObject_CallNoArg(func) \
  166. _PyObject_FastCallDict((func), NULL, 0, NULL)
  167. PyAPI_FUNC(PyObject *) _PyObject_Call_Prepend(
  168. PyObject *callable,
  169. PyObject *obj,
  170. PyObject *args,
  171. PyObject *kwargs);
  172. PyAPI_FUNC(PyObject *) _PyObject_FastCall_Prepend(
  173. PyObject *callable,
  174. PyObject *obj,
  175. PyObject *const *args,
  176. Py_ssize_t nargs);
  177. PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult(PyObject *callable,
  178. PyObject *result,
  179. const char *where);
  180. #endif /* Py_LIMITED_API */
  181. /* Call a callable Python object 'callable', with arguments given by the
  182. tuple 'args'. If no arguments are needed, then 'args' can be *NULL*.
  183. Returns the result of the call on success, or *NULL* on failure.
  184. This is the equivalent of the Python expression:
  185. callable(*args). */
  186. PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable,
  187. PyObject *args);
  188. /* Call a callable Python object, callable, with a variable number of C
  189. arguments. The C arguments are described using a mkvalue-style format
  190. string.
  191. The format may be NULL, indicating that no arguments are provided.
  192. Returns the result of the call on success, or NULL on failure.
  193. This is the equivalent of the Python expression:
  194. callable(arg1, arg2, ...). */
  195. PyAPI_FUNC(PyObject *) PyObject_CallFunction(PyObject *callable,
  196. const char *format, ...);
  197. /* Call the method named 'name' of object 'obj' with a variable number of
  198. C arguments. The C arguments are described by a mkvalue format string.
  199. The format can be NULL, indicating that no arguments are provided.
  200. Returns the result of the call on success, or NULL on failure.
  201. This is the equivalent of the Python expression:
  202. obj.name(arg1, arg2, ...). */
  203. PyAPI_FUNC(PyObject *) PyObject_CallMethod(PyObject *obj,
  204. const char *name,
  205. const char *format, ...);
  206. #ifndef Py_LIMITED_API
  207. /* Like PyObject_CallMethod(), but expect a _Py_Identifier*
  208. as the method name. */
  209. PyAPI_FUNC(PyObject *) _PyObject_CallMethodId(PyObject *obj,
  210. _Py_Identifier *name,
  211. const char *format, ...);
  212. #endif /* !Py_LIMITED_API */
  213. PyAPI_FUNC(PyObject *) _PyObject_CallFunction_SizeT(PyObject *callable,
  214. const char *format,
  215. ...);
  216. PyAPI_FUNC(PyObject *) _PyObject_CallMethod_SizeT(PyObject *obj,
  217. const char *name,
  218. const char *format,
  219. ...);
  220. #ifndef Py_LIMITED_API
  221. PyAPI_FUNC(PyObject *) _PyObject_CallMethodId_SizeT(PyObject *obj,
  222. _Py_Identifier *name,
  223. const char *format,
  224. ...);
  225. #endif /* !Py_LIMITED_API */
  226. /* Call a callable Python object 'callable' with a variable number of C
  227. arguments. The C arguments are provided as PyObject* values, terminated
  228. by a NULL.
  229. Returns the result of the call on success, or NULL on failure.
  230. This is the equivalent of the Python expression:
  231. callable(arg1, arg2, ...). */
  232. PyAPI_FUNC(PyObject *) PyObject_CallFunctionObjArgs(PyObject *callable,
  233. ...);
  234. /* Call the method named 'name' of object 'obj' with a variable number of
  235. C arguments. The C arguments are provided as PyObject* values, terminated
  236. by NULL.
  237. Returns the result of the call on success, or NULL on failure.
  238. This is the equivalent of the Python expression: obj.name(*args). */
  239. PyAPI_FUNC(PyObject *) PyObject_CallMethodObjArgs(
  240. PyObject *obj,
  241. PyObject *name,
  242. ...);
  243. #ifndef Py_LIMITED_API
  244. PyAPI_FUNC(PyObject *) _PyObject_CallMethodIdObjArgs(
  245. PyObject *obj,
  246. struct _Py_Identifier *name,
  247. ...);
  248. #endif /* !Py_LIMITED_API */
  249. /* Implemented elsewhere:
  250. Py_hash_t PyObject_Hash(PyObject *o);
  251. Compute and return the hash, hash_value, of an object, o. On
  252. failure, return -1.
  253. This is the equivalent of the Python expression: hash(o). */
  254. /* Implemented elsewhere:
  255. int PyObject_IsTrue(PyObject *o);
  256. Returns 1 if the object, o, is considered to be true, 0 if o is
  257. considered to be false and -1 on failure.
  258. This is equivalent to the Python expression: not not o. */
  259. /* Implemented elsewhere:
  260. int PyObject_Not(PyObject *o);
  261. Returns 0 if the object, o, is considered to be true, 1 if o is
  262. considered to be false and -1 on failure.
  263. This is equivalent to the Python expression: not o. */
  264. /* Get the type of an object.
  265. On success, returns a type object corresponding to the object type of object
  266. 'o'. On failure, returns NULL.
  267. This is equivalent to the Python expression: type(o) */
  268. PyAPI_FUNC(PyObject *) PyObject_Type(PyObject *o);
  269. /* Return the size of object 'o'. If the object 'o' provides both sequence and
  270. mapping protocols, the sequence size is returned.
  271. On error, -1 is returned.
  272. This is the equivalent to the Python expression: len(o) */
  273. PyAPI_FUNC(Py_ssize_t) PyObject_Size(PyObject *o);
  274. /* For DLL compatibility */
  275. #undef PyObject_Length
  276. PyAPI_FUNC(Py_ssize_t) PyObject_Length(PyObject *o);
  277. #define PyObject_Length PyObject_Size
  278. #ifndef Py_LIMITED_API
  279. PyAPI_FUNC(int) _PyObject_HasLen(PyObject *o);
  280. /* Guess the size of object 'o' using len(o) or o.__length_hint__().
  281. If neither of those return a non-negative value, then return the default
  282. value. If one of the calls fails, this function returns -1. */
  283. PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);
  284. #endif
  285. /* Return element of 'o' corresponding to the object 'key'. Return NULL
  286. on failure.
  287. This is the equivalent of the Python expression: o[key] */
  288. PyAPI_FUNC(PyObject *) PyObject_GetItem(PyObject *o, PyObject *key);
  289. /* Map the object 'key' to the value 'v' into 'o'.
  290. Raise an exception and return -1 on failure; return 0 on success.
  291. This is the equivalent of the Python statement: o[key]=v. */
  292. PyAPI_FUNC(int) PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v);
  293. /* Remove the mapping for the string 'key' from the object 'o'.
  294. Returns -1 on failure.
  295. This is equivalent to the Python statement: del o[key]. */
  296. PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, const char *key);
  297. /* Delete the mapping for the object 'key' from the object 'o'.
  298. Returns -1 on failure.
  299. This is the equivalent of the Python statement: del o[key]. */
  300. PyAPI_FUNC(int) PyObject_DelItem(PyObject *o, PyObject *key);
  301. /* === Old Buffer API ============================================ */
  302. /* FIXME: usage of these should all be replaced in Python itself
  303. but for backwards compatibility we will implement them.
  304. Their usage without a corresponding "unlock" mechanism
  305. may create issues (but they would already be there). */
  306. /* Takes an arbitrary object which must support the (character, single segment)
  307. buffer interface and returns a pointer to a read-only memory location
  308. useable as character based input for subsequent processing.
  309. Return 0 on success. buffer and buffer_len are only set in case no error
  310. occurs. Otherwise, -1 is returned and an exception set. */
  311. PyAPI_FUNC(int) PyObject_AsCharBuffer(PyObject *obj,
  312. const char **buffer,
  313. Py_ssize_t *buffer_len)
  314. Py_DEPRECATED(3.0);
  315. /* Checks whether an arbitrary object supports the (character, single segment)
  316. buffer interface.
  317. Returns 1 on success, 0 on failure. */
  318. PyAPI_FUNC(int) PyObject_CheckReadBuffer(PyObject *obj)
  319. Py_DEPRECATED(3.0);
  320. /* Same as PyObject_AsCharBuffer() except that this API expects (readable,
  321. single segment) buffer interface and returns a pointer to a read-only memory
  322. location which can contain arbitrary data.
  323. 0 is returned on success. buffer and buffer_len are only set in case no
  324. error occurs. Otherwise, -1 is returned and an exception set. */
  325. PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *obj,
  326. const void **buffer,
  327. Py_ssize_t *buffer_len)
  328. Py_DEPRECATED(3.0);
  329. /* Takes an arbitrary object which must support the (writable, single segment)
  330. buffer interface and returns a pointer to a writable memory location in
  331. buffer of size 'buffer_len'.
  332. Return 0 on success. buffer and buffer_len are only set in case no error
  333. occurs. Otherwise, -1 is returned and an exception set. */
  334. PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *obj,
  335. void **buffer,
  336. Py_ssize_t *buffer_len)
  337. Py_DEPRECATED(3.0);
  338. /* === New Buffer API ============================================ */
  339. #ifndef Py_LIMITED_API
  340. /* Return 1 if the getbuffer function is available, otherwise return 0. */
  341. #define PyObject_CheckBuffer(obj) \
  342. (((obj)->ob_type->tp_as_buffer != NULL) && \
  343. ((obj)->ob_type->tp_as_buffer->bf_getbuffer != NULL))
  344. /* This is a C-API version of the getbuffer function call. It checks
  345. to make sure object has the required function pointer and issues the
  346. call.
  347. Returns -1 and raises an error on failure and returns 0 on success. */
  348. PyAPI_FUNC(int) PyObject_GetBuffer(PyObject *obj, Py_buffer *view,
  349. int flags);
  350. /* Get the memory area pointed to by the indices for the buffer given.
  351. Note that view->ndim is the assumed size of indices. */
  352. PyAPI_FUNC(void *) PyBuffer_GetPointer(Py_buffer *view, Py_ssize_t *indices);
  353. /* Return the implied itemsize of the data-format area from a
  354. struct-style description. */
  355. PyAPI_FUNC(int) PyBuffer_SizeFromFormat(const char *);
  356. /* Implementation in memoryobject.c */
  357. PyAPI_FUNC(int) PyBuffer_ToContiguous(void *buf, Py_buffer *view,
  358. Py_ssize_t len, char order);
  359. PyAPI_FUNC(int) PyBuffer_FromContiguous(Py_buffer *view, void *buf,
  360. Py_ssize_t len, char order);
  361. /* Copy len bytes of data from the contiguous chunk of memory
  362. pointed to by buf into the buffer exported by obj. Return
  363. 0 on success and return -1 and raise a PyBuffer_Error on
  364. error (i.e. the object does not have a buffer interface or
  365. it is not working).
  366. If fort is 'F', then if the object is multi-dimensional,
  367. then the data will be copied into the array in
  368. Fortran-style (first dimension varies the fastest). If
  369. fort is 'C', then the data will be copied into the array
  370. in C-style (last dimension varies the fastest). If fort
  371. is 'A', then it does not matter and the copy will be made
  372. in whatever way is more efficient. */
  373. PyAPI_FUNC(int) PyObject_CopyData(PyObject *dest, PyObject *src);
  374. /* Copy the data from the src buffer to the buffer of destination. */
  375. PyAPI_FUNC(int) PyBuffer_IsContiguous(const Py_buffer *view, char fort);
  376. /*Fill the strides array with byte-strides of a contiguous
  377. (Fortran-style if fort is 'F' or C-style otherwise)
  378. array of the given shape with the given number of bytes
  379. per element. */
  380. PyAPI_FUNC(void) PyBuffer_FillContiguousStrides(int ndims,
  381. Py_ssize_t *shape,
  382. Py_ssize_t *strides,
  383. int itemsize,
  384. char fort);
  385. /* Fills in a buffer-info structure correctly for an exporter
  386. that can only share a contiguous chunk of memory of
  387. "unsigned bytes" of the given length.
  388. Returns 0 on success and -1 (with raising an error) on error. */
  389. PyAPI_FUNC(int) PyBuffer_FillInfo(Py_buffer *view, PyObject *o, void *buf,
  390. Py_ssize_t len, int readonly,
  391. int flags);
  392. /* Releases a Py_buffer obtained from getbuffer ParseTuple's "s*". */
  393. PyAPI_FUNC(void) PyBuffer_Release(Py_buffer *view);
  394. #endif /* Py_LIMITED_API */
  395. /* Takes an arbitrary object and returns the result of calling
  396. obj.__format__(format_spec). */
  397. PyAPI_FUNC(PyObject *) PyObject_Format(PyObject *obj,
  398. PyObject *format_spec);
  399. /* ==== Iterators ================================================ */
  400. /* Takes an object and returns an iterator for it.
  401. This is typically a new iterator but if the argument is an iterator, this
  402. returns itself. */
  403. PyAPI_FUNC(PyObject *) PyObject_GetIter(PyObject *);
  404. #define PyIter_Check(obj) \
  405. ((obj)->ob_type->tp_iternext != NULL && \
  406. (obj)->ob_type->tp_iternext != &_PyObject_NextNotImplemented)
  407. /* Takes an iterator object and calls its tp_iternext slot,
  408. returning the next value.
  409. If the iterator is exhausted, this returns NULL without setting an
  410. exception.
  411. NULL with an exception means an error occurred. */
  412. PyAPI_FUNC(PyObject *) PyIter_Next(PyObject *);
  413. /* === Number Protocol ================================================== */
  414. /* Returns 1 if the object 'o' provides numeric protocols, and 0 otherwise.
  415. This function always succeeds. */
  416. PyAPI_FUNC(int) PyNumber_Check(PyObject *o);
  417. /* Returns the result of adding o1 and o2, or NULL on failure.
  418. This is the equivalent of the Python expression: o1 + o2. */
  419. PyAPI_FUNC(PyObject *) PyNumber_Add(PyObject *o1, PyObject *o2);
  420. /* Returns the result of subtracting o2 from o1, or NULL on failure.
  421. This is the equivalent of the Python expression: o1 - o2. */
  422. PyAPI_FUNC(PyObject *) PyNumber_Subtract(PyObject *o1, PyObject *o2);
  423. /* Returns the result of multiplying o1 and o2, or NULL on failure.
  424. This is the equivalent of the Python expression: o1 * o2. */
  425. PyAPI_FUNC(PyObject *) PyNumber_Multiply(PyObject *o1, PyObject *o2);
  426. #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
  427. /* This is the equivalent of the Python expression: o1 @ o2. */
  428. PyAPI_FUNC(PyObject *) PyNumber_MatrixMultiply(PyObject *o1, PyObject *o2);
  429. #endif
  430. /* Returns the result of dividing o1 by o2 giving an integral result,
  431. or NULL on failure.
  432. This is the equivalent of the Python expression: o1 // o2. */
  433. PyAPI_FUNC(PyObject *) PyNumber_FloorDivide(PyObject *o1, PyObject *o2);
  434. /* Returns the result of dividing o1 by o2 giving a float result, or NULL on
  435. failure.
  436. This is the equivalent of the Python expression: o1 / o2. */
  437. PyAPI_FUNC(PyObject *) PyNumber_TrueDivide(PyObject *o1, PyObject *o2);
  438. /* Returns the remainder of dividing o1 by o2, or NULL on failure.
  439. This is the equivalent of the Python expression: o1 % o2. */
  440. PyAPI_FUNC(PyObject *) PyNumber_Remainder(PyObject *o1, PyObject *o2);
  441. /* See the built-in function divmod.
  442. Returns NULL on failure.
  443. This is the equivalent of the Python expression: divmod(o1, o2). */
  444. PyAPI_FUNC(PyObject *) PyNumber_Divmod(PyObject *o1, PyObject *o2);
  445. /* See the built-in function pow. Returns NULL on failure.
  446. This is the equivalent of the Python expression: pow(o1, o2, o3),
  447. where o3 is optional. */
  448. PyAPI_FUNC(PyObject *) PyNumber_Power(PyObject *o1, PyObject *o2,
  449. PyObject *o3);
  450. /* Returns the negation of o on success, or NULL on failure.
  451. This is the equivalent of the Python expression: -o. */
  452. PyAPI_FUNC(PyObject *) PyNumber_Negative(PyObject *o);
  453. /* Returns the positive of o on success, or NULL on failure.
  454. This is the equivalent of the Python expression: +o. */
  455. PyAPI_FUNC(PyObject *) PyNumber_Positive(PyObject *o);
  456. /* Returns the absolute value of 'o', or NULL on failure.
  457. This is the equivalent of the Python expression: abs(o). */
  458. PyAPI_FUNC(PyObject *) PyNumber_Absolute(PyObject *o);
  459. /* Returns the bitwise negation of 'o' on success, or NULL on failure.
  460. This is the equivalent of the Python expression: ~o. */
  461. PyAPI_FUNC(PyObject *) PyNumber_Invert(PyObject *o);
  462. /* Returns the result of left shifting o1 by o2 on success, or NULL on failure.
  463. This is the equivalent of the Python expression: o1 << o2. */
  464. PyAPI_FUNC(PyObject *) PyNumber_Lshift(PyObject *o1, PyObject *o2);
  465. /* Returns the result of right shifting o1 by o2 on success, or NULL on
  466. failure.
  467. This is the equivalent of the Python expression: o1 >> o2. */
  468. PyAPI_FUNC(PyObject *) PyNumber_Rshift(PyObject *o1, PyObject *o2);
  469. /* Returns the result of bitwise and of o1 and o2 on success, or NULL on
  470. failure.
  471. This is the equivalent of the Python expression: o1 & o2. */
  472. PyAPI_FUNC(PyObject *) PyNumber_And(PyObject *o1, PyObject *o2);
  473. /* Returns the bitwise exclusive or of o1 by o2 on success, or NULL on failure.
  474. This is the equivalent of the Python expression: o1 ^ o2. */
  475. PyAPI_FUNC(PyObject *) PyNumber_Xor(PyObject *o1, PyObject *o2);
  476. /* Returns the result of bitwise or on o1 and o2 on success, or NULL on
  477. failure.
  478. This is the equivalent of the Python expression: o1 | o2. */
  479. PyAPI_FUNC(PyObject *) PyNumber_Or(PyObject *o1, PyObject *o2);
  480. #define PyIndex_Check(obj) \
  481. ((obj)->ob_type->tp_as_number != NULL && \
  482. (obj)->ob_type->tp_as_number->nb_index != NULL)
  483. /* Returns the object 'o' converted to a Python int, or NULL with an exception
  484. raised on failure. */
  485. PyAPI_FUNC(PyObject *) PyNumber_Index(PyObject *o);
  486. /* Returns the object 'o' converted to Py_ssize_t by going through
  487. PyNumber_Index() first.
  488. If an overflow error occurs while converting the int to Py_ssize_t, then the
  489. second argument 'exc' is the error-type to return. If it is NULL, then the
  490. overflow error is cleared and the value is clipped. */
  491. PyAPI_FUNC(Py_ssize_t) PyNumber_AsSsize_t(PyObject *o, PyObject *exc);
  492. /* Returns the object 'o' converted to an integer object on success, or NULL
  493. on failure.
  494. This is the equivalent of the Python expression: int(o). */
  495. PyAPI_FUNC(PyObject *) PyNumber_Long(PyObject *o);
  496. /* Returns the object 'o' converted to a float object on success, or NULL
  497. on failure.
  498. This is the equivalent of the Python expression: float(o). */
  499. PyAPI_FUNC(PyObject *) PyNumber_Float(PyObject *o);
  500. /* --- In-place variants of (some of) the above number protocol functions -- */
  501. /* Returns the result of adding o2 to o1, possibly in-place, or NULL
  502. on failure.
  503. This is the equivalent of the Python expression: o1 += o2. */
  504. PyAPI_FUNC(PyObject *) PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2);
  505. /* Returns the result of subtracting o2 from o1, possibly in-place or
  506. NULL on failure.
  507. This is the equivalent of the Python expression: o1 -= o2. */
  508. PyAPI_FUNC(PyObject *) PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2);
  509. /* Returns the result of multiplying o1 by o2, possibly in-place, or NULL on
  510. failure.
  511. This is the equivalent of the Python expression: o1 *= o2. */
  512. PyAPI_FUNC(PyObject *) PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2);
  513. #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
  514. /* This is the equivalent of the Python expression: o1 @= o2. */
  515. PyAPI_FUNC(PyObject *) PyNumber_InPlaceMatrixMultiply(PyObject *o1, PyObject *o2);
  516. #endif
  517. /* Returns the result of dividing o1 by o2 giving an integral result, possibly
  518. in-place, or NULL on failure.
  519. This is the equivalent of the Python expression: o1 /= o2. */
  520. PyAPI_FUNC(PyObject *) PyNumber_InPlaceFloorDivide(PyObject *o1,
  521. PyObject *o2);
  522. /* Returns the result of dividing o1 by o2 giving a float result, possibly
  523. in-place, or null on failure.
  524. This is the equivalent of the Python expression: o1 /= o2. */
  525. PyAPI_FUNC(PyObject *) PyNumber_InPlaceTrueDivide(PyObject *o1,
  526. PyObject *o2);
  527. /* Returns the remainder of dividing o1 by o2, possibly in-place, or NULL on
  528. failure.
  529. This is the equivalent of the Python expression: o1 %= o2. */
  530. PyAPI_FUNC(PyObject *) PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2);
  531. /* Returns the result of raising o1 to the power of o2, possibly in-place,
  532. or NULL on failure.
  533. This is the equivalent of the Python expression: o1 **= o2,
  534. or o1 = pow(o1, o2, o3) if o3 is present. */
  535. PyAPI_FUNC(PyObject *) PyNumber_InPlacePower(PyObject *o1, PyObject *o2,
  536. PyObject *o3);
  537. /* Returns the result of left shifting o1 by o2, possibly in-place, or NULL
  538. on failure.
  539. This is the equivalent of the Python expression: o1 <<= o2. */
  540. PyAPI_FUNC(PyObject *) PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2);
  541. /* Returns the result of right shifting o1 by o2, possibly in-place or NULL
  542. on failure.
  543. This is the equivalent of the Python expression: o1 >>= o2. */
  544. PyAPI_FUNC(PyObject *) PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2);
  545. /* Returns the result of bitwise and of o1 and o2, possibly in-place, or NULL
  546. on failure.
  547. This is the equivalent of the Python expression: o1 &= o2. */
  548. PyAPI_FUNC(PyObject *) PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2);
  549. /* Returns the bitwise exclusive or of o1 by o2, possibly in-place, or NULL
  550. on failure.
  551. This is the equivalent of the Python expression: o1 ^= o2. */
  552. PyAPI_FUNC(PyObject *) PyNumber_InPlaceXor(PyObject *o1, PyObject *o2);
  553. /* Returns the result of bitwise or of o1 and o2, possibly in-place,
  554. or NULL on failure.
  555. This is the equivalent of the Python expression: o1 |= o2. */
  556. PyAPI_FUNC(PyObject *) PyNumber_InPlaceOr(PyObject *o1, PyObject *o2);
  557. /* Returns the integer n converted to a string with a base, with a base
  558. marker of 0b, 0o or 0x prefixed if applicable.
  559. If n is not an int object, it is converted with PyNumber_Index first. */
  560. PyAPI_FUNC(PyObject *) PyNumber_ToBase(PyObject *n, int base);
  561. /* === Sequence protocol ================================================ */
  562. /* Return 1 if the object provides sequence protocol, and zero
  563. otherwise.
  564. This function always succeeds. */
  565. PyAPI_FUNC(int) PySequence_Check(PyObject *o);
  566. /* Return the size of sequence object o, or -1 on failure. */
  567. PyAPI_FUNC(Py_ssize_t) PySequence_Size(PyObject *o);
  568. /* For DLL compatibility */
  569. #undef PySequence_Length
  570. PyAPI_FUNC(Py_ssize_t) PySequence_Length(PyObject *o);
  571. #define PySequence_Length PySequence_Size
  572. /* Return the concatenation of o1 and o2 on success, and NULL on failure.
  573. This is the equivalent of the Python expression: o1 + o2. */
  574. PyAPI_FUNC(PyObject *) PySequence_Concat(PyObject *o1, PyObject *o2);
  575. /* Return the result of repeating sequence object 'o' 'count' times,
  576. or NULL on failure.
  577. This is the equivalent of the Python expression: o * count. */
  578. PyAPI_FUNC(PyObject *) PySequence_Repeat(PyObject *o, Py_ssize_t count);
  579. /* Return the ith element of o, or NULL on failure.
  580. This is the equivalent of the Python expression: o[i]. */
  581. PyAPI_FUNC(PyObject *) PySequence_GetItem(PyObject *o, Py_ssize_t i);
  582. /* Return the slice of sequence object o between i1 and i2, or NULL on failure.
  583. This is the equivalent of the Python expression: o[i1:i2]. */
  584. PyAPI_FUNC(PyObject *) PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2);
  585. /* Assign object 'v' to the ith element of the sequence 'o'. Raise an exception
  586. and return -1 on failure; return 0 on success.
  587. This is the equivalent of the Python statement o[i] = v. */
  588. PyAPI_FUNC(int) PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v);
  589. /* Delete the 'i'-th element of the sequence 'v'. Returns -1 on failure.
  590. This is the equivalent of the Python statement: del o[i]. */
  591. PyAPI_FUNC(int) PySequence_DelItem(PyObject *o, Py_ssize_t i);
  592. /* Assign the sequence object 'v' to the slice in sequence object 'o',
  593. from 'i1' to 'i2'. Returns -1 on failure.
  594. This is the equivalent of the Python statement: o[i1:i2] = v. */
  595. PyAPI_FUNC(int) PySequence_SetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2,
  596. PyObject *v);
  597. /* Delete the slice in sequence object 'o' from 'i1' to 'i2'.
  598. Returns -1 on failure.
  599. This is the equivalent of the Python statement: del o[i1:i2]. */
  600. PyAPI_FUNC(int) PySequence_DelSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2);
  601. /* Returns the sequence 'o' as a tuple on success, and NULL on failure.
  602. This is equivalent to the Python expression: tuple(o). */
  603. PyAPI_FUNC(PyObject *) PySequence_Tuple(PyObject *o);
  604. /* Returns the sequence 'o' as a list on success, and NULL on failure.
  605. This is equivalent to the Python expression: list(o) */
  606. PyAPI_FUNC(PyObject *) PySequence_List(PyObject *o);
  607. /* Return the sequence 'o' as a list, unless it's already a tuple or list.
  608. Use PySequence_Fast_GET_ITEM to access the members of this list, and
  609. PySequence_Fast_GET_SIZE to get its length.
  610. Returns NULL on failure. If the object does not support iteration, raises a
  611. TypeError exception with 'm' as the message text. */
  612. PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m);
  613. /* Return the size of the sequence 'o', assuming that 'o' was returned by
  614. PySequence_Fast and is not NULL. */
  615. #define PySequence_Fast_GET_SIZE(o) \
  616. (PyList_Check(o) ? PyList_GET_SIZE(o) : PyTuple_GET_SIZE(o))
  617. /* Return the 'i'-th element of the sequence 'o', assuming that o was returned
  618. by PySequence_Fast, and that i is within bounds. */
  619. #define PySequence_Fast_GET_ITEM(o, i)\
  620. (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
  621. /* Assume tp_as_sequence and sq_item exist and that 'i' does not
  622. need to be corrected for a negative index. */
  623. #define PySequence_ITEM(o, i)\
  624. ( Py_TYPE(o)->tp_as_sequence->sq_item(o, i) )
  625. /* Return a pointer to the underlying item array for
  626. an object retured by PySequence_Fast */
  627. #define PySequence_Fast_ITEMS(sf) \
  628. (PyList_Check(sf) ? ((PyListObject *)(sf))->ob_item \
  629. : ((PyTupleObject *)(sf))->ob_item)
  630. /* Return the number of occurrences on value on 'o', that is, return
  631. the number of keys for which o[key] == value.
  632. On failure, return -1. This is equivalent to the Python expression:
  633. o.count(value). */
  634. PyAPI_FUNC(Py_ssize_t) PySequence_Count(PyObject *o, PyObject *value);
  635. /* Return 1 if 'ob' is in the sequence 'seq'; 0 if 'ob' is not in the sequence
  636. 'seq'; -1 on error.
  637. Use __contains__ if possible, else _PySequence_IterSearch(). */
  638. PyAPI_FUNC(int) PySequence_Contains(PyObject *seq, PyObject *ob);
  639. #ifndef Py_LIMITED_API
  640. #define PY_ITERSEARCH_COUNT 1
  641. #define PY_ITERSEARCH_INDEX 2
  642. #define PY_ITERSEARCH_CONTAINS 3
  643. /* Iterate over seq.
  644. Result depends on the operation:
  645. PY_ITERSEARCH_COUNT: return # of times obj appears in seq; -1 if
  646. error.
  647. PY_ITERSEARCH_INDEX: return 0-based index of first occurrence of
  648. obj in seq; set ValueError and return -1 if none found;
  649. also return -1 on error.
  650. PY_ITERSEARCH_CONTAINS: return 1 if obj in seq, else 0; -1 on
  651. error. */
  652. PyAPI_FUNC(Py_ssize_t) _PySequence_IterSearch(PyObject *seq,
  653. PyObject *obj, int operation);
  654. #endif
  655. /* For DLL-level backwards compatibility */
  656. #undef PySequence_In
  657. /* Determine if the sequence 'o' contains 'value'. If an item in 'o' is equal
  658. to 'value', return 1, otherwise return 0. On error, return -1.
  659. This is equivalent to the Python expression: value in o. */
  660. PyAPI_FUNC(int) PySequence_In(PyObject *o, PyObject *value);
  661. /* For source-level backwards compatibility */
  662. #define PySequence_In PySequence_Contains
  663. /* Return the first index for which o[i] == value.
  664. On error, return -1.
  665. This is equivalent to the Python expression: o.index(value). */
  666. PyAPI_FUNC(Py_ssize_t) PySequence_Index(PyObject *o, PyObject *value);
  667. /* --- In-place versions of some of the above Sequence functions --- */
  668. /* Append sequence 'o2' to sequence 'o1', in-place when possible. Return the
  669. resulting object, which could be 'o1', or NULL on failure.
  670. This is the equivalent of the Python expression: o1 += o2. */
  671. PyAPI_FUNC(PyObject *) PySequence_InPlaceConcat(PyObject *o1, PyObject *o2);
  672. /* Repeat sequence 'o' by 'count', in-place when possible. Return the resulting
  673. object, which could be 'o', or NULL on failure.
  674. This is the equivalent of the Python expression: o1 *= count. */
  675. PyAPI_FUNC(PyObject *) PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count);
  676. /* === Mapping protocol ================================================= */
  677. /* Return 1 if the object provides mapping protocol, and 0 otherwise.
  678. This function always succeeds. */
  679. PyAPI_FUNC(int) PyMapping_Check(PyObject *o);
  680. /* Returns the number of keys in mapping object 'o' on success, and -1 on
  681. failure. This is equivalent to the Python expression: len(o). */
  682. PyAPI_FUNC(Py_ssize_t) PyMapping_Size(PyObject *o);
  683. /* For DLL compatibility */
  684. #undef PyMapping_Length
  685. PyAPI_FUNC(Py_ssize_t) PyMapping_Length(PyObject *o);
  686. #define PyMapping_Length PyMapping_Size
  687. /* Implemented as a macro:
  688. int PyMapping_DelItemString(PyObject *o, const char *key);
  689. Remove the mapping for the string 'key' from the mapping 'o'. Returns -1 on
  690. failure.
  691. This is equivalent to the Python statement: del o[key]. */
  692. #define PyMapping_DelItemString(O,K) PyObject_DelItemString((O),(K))
  693. /* Implemented as a macro:
  694. int PyMapping_DelItem(PyObject *o, PyObject *key);
  695. Remove the mapping for the object 'key' from the mapping object 'o'.
  696. Returns -1 on failure.
  697. This is equivalent to the Python statement: del o[key]. */
  698. #define PyMapping_DelItem(O,K) PyObject_DelItem((O),(K))
  699. /* On success, return 1 if the mapping object 'o' has the key 'key',
  700. and 0 otherwise.
  701. This is equivalent to the Python expression: key in o.
  702. This function always succeeds. */
  703. PyAPI_FUNC(int) PyMapping_HasKeyString(PyObject *o, const char *key);
  704. /* Return 1 if the mapping object has the key 'key', and 0 otherwise.
  705. This is equivalent to the Python expression: key in o.
  706. This function always succeeds. */
  707. PyAPI_FUNC(int) PyMapping_HasKey(PyObject *o, PyObject *key);
  708. /* On success, return a list or tuple of the keys in mapping object 'o'.
  709. On failure, return NULL. */
  710. PyAPI_FUNC(PyObject *) PyMapping_Keys(PyObject *o);
  711. /* On success, return a list or tuple of the values in mapping object 'o'.
  712. On failure, return NULL. */
  713. PyAPI_FUNC(PyObject *) PyMapping_Values(PyObject *o);
  714. /* On success, return a list or tuple of the items in mapping object 'o',
  715. where each item is a tuple containing a key-value pair. On failure, return
  716. NULL. */
  717. PyAPI_FUNC(PyObject *) PyMapping_Items(PyObject *o);
  718. /* Return element of 'o' corresponding to the string 'key' or NULL on failure.
  719. This is the equivalent of the Python expression: o[key]. */
  720. PyAPI_FUNC(PyObject *) PyMapping_GetItemString(PyObject *o,
  721. const char *key);
  722. /* Map the string 'key' to the value 'v' in the mapping 'o'.
  723. Returns -1 on failure.
  724. This is the equivalent of the Python statement: o[key]=v. */
  725. PyAPI_FUNC(int) PyMapping_SetItemString(PyObject *o, const char *key,
  726. PyObject *value);
  727. /* isinstance(object, typeorclass) */
  728. PyAPI_FUNC(int) PyObject_IsInstance(PyObject *object, PyObject *typeorclass);
  729. /* issubclass(object, typeorclass) */
  730. PyAPI_FUNC(int) PyObject_IsSubclass(PyObject *object, PyObject *typeorclass);
  731. #ifndef Py_LIMITED_API
  732. PyAPI_FUNC(int) _PyObject_RealIsInstance(PyObject *inst, PyObject *cls);
  733. PyAPI_FUNC(int) _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls);
  734. PyAPI_FUNC(char *const *) _PySequence_BytesToCharpArray(PyObject* self);
  735. PyAPI_FUNC(void) _Py_FreeCharPArray(char *const array[]);
  736. /* For internal use by buffer API functions */
  737. PyAPI_FUNC(void) _Py_add_one_to_index_F(int nd, Py_ssize_t *index,
  738. const Py_ssize_t *shape);
  739. PyAPI_FUNC(void) _Py_add_one_to_index_C(int nd, Py_ssize_t *index,
  740. const Py_ssize_t *shape);
  741. /* Convert Python int to Py_ssize_t. Do nothing if the argument is None. */
  742. PyAPI_FUNC(int) _Py_convert_optional_to_ssize_t(PyObject *, void *);
  743. #endif /* !Py_LIMITED_API */
  744. #ifdef __cplusplus
  745. }
  746. #endif
  747. #endif /* Py_ABSTRACTOBJECT_H */
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...