FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codon/stdlib/internal/python.codon at develop · strider4560/codon · GitHub
strider4560
/
codon
Public
forked from
exaloop/codon
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codon
/
stdlib
/
internal
/
python.codon
Copy path
More file actions
More file actions
Latest commit
History
History
History
2086 lines (1810 loc) · 76.5 KB
Breadcrumbs
codon
/
stdlib
/
internal
/
python.codon
Copy path
File metadata and controls
2086 lines (1810 loc) · 76.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
# Copyright (C) 2022-2026 Exaloop Inc. <https://exaloop.io>
import
os
from
gc
import
atomic
,
alloc_uncollectable
from
internal
.
dlopen
import
*
import
internal
.
static
as
static
# general
Py_DecRef
=
Function
[[
cobj
],
NoneType
](
cobj
())
Py_IncRef
=
Function
[[
cobj
],
NoneType
](
cobj
())
Py_Initialize
=
Function
[[],
NoneType
](
cobj
())
PyImport_AddModule
=
Function
[[
cobj
],
cobj
](
cobj
())
PyImport_AddModuleObject
=
Function
[[
cobj
],
cobj
](
cobj
())
PyImport_ImportModule
=
Function
[[
cobj
],
cobj
](
cobj
())
PyRun_SimpleString
=
Function
[[
cobj
],
NoneType
](
cobj
())
PyEval_GetGlobals
=
Function
[[],
cobj
](
cobj
())
PyEval_GetBuiltins
=
Function
[[],
cobj
](
cobj
())
PyOS_setsig
=
Function
[[
i32
,
cobj
],
cobj
](
cobj
())
# conversions
PyLong_AsLong
=
Function
[[
cobj
],
int
](
cobj
())
PyLong_FromLong
=
Function
[[
int
],
cobj
](
cobj
())
PyFloat_AsDouble
=
Function
[[
cobj
],
float
](
cobj
())
PyFloat_FromDouble
=
Function
[[
float
],
cobj
](
cobj
())
PyBool_FromLong
=
Function
[[
int
],
cobj
](
cobj
())
PyBytes_AsString
=
Function
[[
cobj
],
cobj
](
cobj
())
PyBytes_Size
=
Function
[[
cobj
],
int
](
cobj
())
PyList_New
=
Function
[[
int
],
cobj
](
cobj
())
PyList_Size
=
Function
[[
cobj
],
int
](
cobj
())
PyList_GetItem
=
Function
[[
cobj
,
int
],
cobj
](
cobj
())
PyList_SetItem
=
Function
[[
cobj
,
int
,
cobj
],
cobj
](
cobj
())
PyDict_New
=
Function
[[],
cobj
](
cobj
())
PyDict_Next
=
Function
[[
cobj
,
Ptr
[
int
],
Ptr
[
cobj
],
Ptr
[
cobj
]],
int
](
cobj
())
PyDict_GetItem
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyDict_GetItemString
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyDict_SetItem
=
Function
[[
cobj
,
cobj
,
cobj
],
cobj
](
cobj
())
PyDict_Size
=
Function
[[
cobj
],
int
](
cobj
())
PySet_Add
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PySet_New
=
Function
[[
cobj
],
cobj
](
cobj
())
PyTuple_New
=
Function
[[
int
],
cobj
](
cobj
())
PyTuple_Size
=
Function
[[
cobj
],
int
](
cobj
())
PyTuple_GetItem
=
Function
[[
cobj
,
int
],
cobj
](
cobj
())
PyTuple_SetItem
=
Function
[[
cobj
,
int
,
cobj
],
i32
](
cobj
())
PyUnicode_AsEncodedString
=
Function
[[
cobj
,
cobj
,
cobj
],
cobj
](
cobj
())
PyUnicode_DecodeFSDefaultAndSize
=
Function
[[
cobj
,
int
],
cobj
](
cobj
())
PyUnicode_FromString
=
Function
[[
cobj
],
cobj
](
cobj
())
PyComplex_FromDoubles
=
Function
[[
float
,
float
],
cobj
](
cobj
())
PyComplex_RealAsDouble
=
Function
[[
cobj
],
float
](
cobj
())
PyComplex_ImagAsDouble
=
Function
[[
cobj
],
float
](
cobj
())
PyIter_Next
=
Function
[[
cobj
],
cobj
](
cobj
())
PySlice_New
=
Function
[[
cobj
,
cobj
,
cobj
],
cobj
](
cobj
())
PySlice_Unpack
=
Function
[[
cobj
,
Ptr
[
int
],
Ptr
[
int
],
Ptr
[
int
]],
int
](
cobj
())
PyCapsule_New
=
Function
[[
cobj
,
cobj
,
cobj
],
cobj
](
cobj
())
PyCapsule_GetPointer
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
# number
PyNumber_Add
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_Subtract
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_Multiply
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_MatrixMultiply
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_FloorDivide
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_TrueDivide
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_Remainder
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_Divmod
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_Power
=
Function
[[
cobj
,
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_Negative
=
Function
[[
cobj
],
cobj
](
cobj
())
PyNumber_Positive
=
Function
[[
cobj
],
cobj
](
cobj
())
PyNumber_Absolute
=
Function
[[
cobj
],
cobj
](
cobj
())
PyNumber_Invert
=
Function
[[
cobj
],
cobj
](
cobj
())
PyNumber_Lshift
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_Rshift
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_And
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_Xor
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_Or
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_InPlaceAdd
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_InPlaceSubtract
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_InPlaceMultiply
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_InPlaceMatrixMultiply
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_InPlaceFloorDivide
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_InPlaceTrueDivide
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_InPlaceRemainder
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_InPlacePower
=
Function
[[
cobj
,
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_InPlaceLshift
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_InPlaceRshift
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_InPlaceAnd
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_InPlaceXor
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_InPlaceOr
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyNumber_Long
=
Function
[[
cobj
],
cobj
](
cobj
())
PyNumber_Float
=
Function
[[
cobj
],
cobj
](
cobj
())
PyNumber_Index
=
Function
[[
cobj
],
cobj
](
cobj
())
# object
PyObject_Call
=
Function
[[
cobj
,
cobj
,
cobj
],
cobj
](
cobj
())
PyObject_CallNoArgs
=
Function
[[
cobj
],
cobj
](
cobj
())
PyObject_CallOneArg
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyObject_GetAttr
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyObject_GetAttrString
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyObject_GetIter
=
Function
[[
cobj
],
cobj
](
cobj
())
PyObject_HasAttrString
=
Function
[[
cobj
,
cobj
],
int
](
cobj
())
PyObject_IsTrue
=
Function
[[
cobj
],
i32
](
cobj
())
PyObject_Length
=
Function
[[
cobj
],
int
](
cobj
())
PyObject_LengthHint
=
Function
[[
cobj
,
int
],
int
](
cobj
())
PyObject_SetAttrString
=
Function
[[
cobj
,
cobj
,
cobj
],
cobj
](
cobj
())
PyObject_Str
=
Function
[[
cobj
],
cobj
](
cobj
())
PyObject_Repr
=
Function
[[
cobj
],
cobj
](
cobj
())
PyObject_Hash
=
Function
[[
cobj
],
int
](
cobj
())
PyObject_GetItem
=
Function
[[
cobj
,
cobj
],
cobj
](
cobj
())
PyObject_SetItem
=
Function
[[
cobj
,
cobj
,
cobj
],
int
](
cobj
())
PyObject_DelItem
=
Function
[[
cobj
,
cobj
],
int
](
cobj
())
PyObject_RichCompare
=
Function
[[
cobj
,
cobj
,
i32
],
cobj
](
cobj
())
PyObject_IsInstance
=
Function
[[
cobj
,
cobj
],
i32
](
cobj
())
# error handling
PyErr_Fetch
=
Function
[[
Ptr
[
cobj
],
Ptr
[
cobj
],
Ptr
[
cobj
]],
NoneType
](
cobj
())
PyErr_NormalizeException
=
Function
[[
Ptr
[
cobj
],
Ptr
[
cobj
],
Ptr
[
cobj
]],
NoneType
](
cobj
())
PyErr_SetString
=
Function
[[
cobj
,
cobj
],
NoneType
](
cobj
())
# constants
Py_None
=
cobj
()
Py_True
=
cobj
()
Py_False
=
cobj
()
Py_Ellipsis
=
cobj
()
Py_NotImplemented
=
cobj
()
Py_LT
=
0
Py_LE
=
1
Py_EQ
=
2
Py_NE
=
3
Py_GT
=
4
Py_GE
=
5
# types
PyLong_Type
=
cobj
()
PyFloat_Type
=
cobj
()
PyBool_Type
=
cobj
()
PyUnicode_Type
=
cobj
()
PyBytes_Type
=
cobj
()
PyComplex_Type
=
cobj
()
PyList_Type
=
cobj
()
PyDict_Type
=
cobj
()
PySet_Type
=
cobj
()
PyTuple_Type
=
cobj
()
PySlice_Type
=
cobj
()
PyCapsule_Type
=
cobj
()
# exceptions
PyExc_BaseException
=
cobj
()
PyExc_Exception
=
cobj
()
PyExc_NameError
=
cobj
()
PyExc_OSError
=
cobj
()
PyExc_IOError
=
cobj
()
PyExc_ValueError
=
cobj
()
PyExc_LookupError
=
cobj
()
PyExc_IndexError
=
cobj
()
PyExc_KeyError
=
cobj
()
PyExc_TypeError
=
cobj
()
PyExc_ArithmeticError
=
cobj
()
PyExc_ZeroDivisionError
=
cobj
()
PyExc_OverflowError
=
cobj
()
PyExc_AttributeError
=
cobj
()
PyExc_RuntimeError
=
cobj
()
PyExc_NotImplementedError
=
cobj
()
PyExc_StopIteration
=
cobj
()
PyExc_AssertionError
=
cobj
()
PyExc_EOFError
=
cobj
()
PyExc_SystemExit
=
cobj
()
_PY_MODULE_CACHE
=
Dict
[
str
,
pyobj
]()
_PY_INIT
=
"""
import io
clsf = None
clsa = None
plt = None
try:
import matplotlib.figure
import matplotlib.pyplot
plt = matplotlib.pyplot
clsf = matplotlib.figure.Figure
clsa = matplotlib.artist.Artist
except ModuleNotFoundError:
pass
def __codon_repr__(fig):
if clsf and isinstance(fig, clsf):
stream = io.StringIO()
fig.savefig(stream, format="svg")
return 'image/svg+xml', stream.getvalue()
elif clsa and isinstance(fig, list) and all(
isinstance(i, clsa) for i in fig
):
stream = io.StringIO()
plt.gcf().savefig(stream, format="svg")
return 'image/svg+xml', stream.getvalue()
elif hasattr(fig, "_repr_html_"):
return 'text/html', fig._repr_html_()
else:
return 'text/plain', fig.__repr__()
"""
_PY_INITIALIZED
=
False
def
init_handles_dlopen
(
py_handle
:
cobj
):
global
Py_DecRef
global
Py_IncRef
global
Py_Initialize
global
PyImport_AddModule
global
PyImport_AddModuleObject
global
PyImport_ImportModule
global
PyRun_SimpleString
global
PyEval_GetGlobals
global
PyEval_GetBuiltins
global
PyOS_setsig
global
PyLong_AsLong
global
PyLong_FromLong
global
PyFloat_AsDouble
global
PyFloat_FromDouble
global
PyBool_FromLong
global
PyBytes_AsString
global
PyBytes_Size
global
PyList_New
global
PyList_Size
global
PyList_GetItem
global
PyList_SetItem
global
PyDict_New
global
PyDict_Next
global
PyDict_GetItem
global
PyDict_GetItemString
global
PyDict_SetItem
global
PyDict_Size
global
PySet_Add
global
PySet_New
global
PyTuple_New
global
PyTuple_Size
global
PyTuple_GetItem
global
PyTuple_SetItem
global
PyUnicode_AsEncodedString
global
PyUnicode_DecodeFSDefaultAndSize
global
PyUnicode_FromString
global
PyComplex_FromDoubles
global
PyComplex_RealAsDouble
global
PyComplex_ImagAsDouble
global
PyIter_Next
global
PySlice_New
global
PySlice_Unpack
global
PyCapsule_New
global
PyCapsule_GetPointer
global
PyNumber_Add
global
PyNumber_Subtract
global
PyNumber_Multiply
global
PyNumber_MatrixMultiply
global
PyNumber_FloorDivide
global
PyNumber_TrueDivide
global
PyNumber_Remainder
global
PyNumber_Divmod
global
PyNumber_Power
global
PyNumber_Negative
global
PyNumber_Positive
global
PyNumber_Absolute
global
PyNumber_Invert
global
PyNumber_Lshift
global
PyNumber_Rshift
global
PyNumber_And
global
PyNumber_Xor
global
PyNumber_Or
global
PyNumber_InPlaceAdd
global
PyNumber_InPlaceSubtract
global
PyNumber_InPlaceMultiply
global
PyNumber_InPlaceMatrixMultiply
global
PyNumber_InPlaceFloorDivide
global
PyNumber_InPlaceTrueDivide
global
PyNumber_InPlaceRemainder
global
PyNumber_InPlacePower
global
PyNumber_InPlaceLshift
global
PyNumber_InPlaceRshift
global
PyNumber_InPlaceAnd
global
PyNumber_InPlaceXor
global
PyNumber_InPlaceOr
global
PyNumber_Long
global
PyNumber_Float
global
PyNumber_Index
global
PyObject_Call
global
PyObject_CallNoArgs
global
PyObject_CallOneArg
global
PyObject_GetAttr
global
PyObject_GetAttrString
global
PyObject_GetIter
global
PyObject_HasAttrString
global
PyObject_IsTrue
global
PyObject_Length
global
PyObject_LengthHint
global
PyObject_SetAttrString
global
PyObject_Str
global
PyObject_Repr
global
PyObject_Hash
global
PyObject_GetItem
global
PyObject_SetItem
global
PyObject_DelItem
global
PyObject_RichCompare
global
PyObject_IsInstance
global
PyErr_Fetch
global
PyErr_NormalizeException
global
PyErr_SetString
global
Py_None
global
Py_True
global
Py_False
global
Py_Ellipsis
global
Py_NotImplemented
global
PyLong_Type
global
PyFloat_Type
global
PyBool_Type
global
PyUnicode_Type
global
PyBytes_Type
global
PyComplex_Type
global
PyList_Type
global
PyDict_Type
global
PySet_Type
global
PyTuple_Type
global
PySlice_Type
global
PyCapsule_Type
global
PyExc_BaseException
global
PyExc_Exception
global
PyExc_NameError
global
PyExc_OSError
global
PyExc_IOError
global
PyExc_ValueError
global
PyExc_LookupError
global
PyExc_IndexError
global
PyExc_KeyError
global
PyExc_TypeError
global
PyExc_ArithmeticError
global
PyExc_ZeroDivisionError
global
PyExc_OverflowError
global
PyExc_AttributeError
global
PyExc_RuntimeError
global
PyExc_NotImplementedError
global
PyExc_StopIteration
global
PyExc_AssertionError
global
PyExc_EOFError
global
PyExc_SystemExit
Py_DecRef
=
dlsym
(
py_handle
,
"Py_DecRef"
)
Py_IncRef
=
dlsym
(
py_handle
,
"Py_IncRef"
)
Py_Initialize
=
dlsym
(
py_handle
,
"Py_Initialize"
)
PyImport_AddModule
=
dlsym
(
py_handle
,
"PyImport_AddModule"
)
PyImport_AddModuleObject
=
dlsym
(
py_handle
,
"PyImport_AddModuleObject"
)
PyImport_ImportModule
=
dlsym
(
py_handle
,
"PyImport_ImportModule"
)
PyRun_SimpleString
=
dlsym
(
py_handle
,
"PyRun_SimpleString"
)
PyEval_GetGlobals
=
dlsym
(
py_handle
,
"PyEval_GetGlobals"
)
PyEval_GetBuiltins
=
dlsym
(
py_handle
,
"PyEval_GetBuiltins"
)
PyOS_setsig
=
dlsym
(
py_handle
,
"PyOS_setsig"
)
PyLong_AsLong
=
dlsym
(
py_handle
,
"PyLong_AsLong"
)
PyLong_FromLong
=
dlsym
(
py_handle
,
"PyLong_FromLong"
)
PyFloat_AsDouble
=
dlsym
(
py_handle
,
"PyFloat_AsDouble"
)
PyFloat_FromDouble
=
dlsym
(
py_handle
,
"PyFloat_FromDouble"
)
PyBool_FromLong
=
dlsym
(
py_handle
,
"PyBool_FromLong"
)
PyBytes_AsString
=
dlsym
(
py_handle
,
"PyBytes_AsString"
)
PyBytes_Size
=
dlsym
(
py_handle
,
"PyBytes_Size"
)
PyList_New
=
dlsym
(
py_handle
,
"PyList_New"
)
PyList_Size
=
dlsym
(
py_handle
,
"PyList_Size"
)
PyList_GetItem
=
dlsym
(
py_handle
,
"PyList_GetItem"
)
PyList_SetItem
=
dlsym
(
py_handle
,
"PyList_SetItem"
)
PyDict_New
=
dlsym
(
py_handle
,
"PyDict_New"
)
PyDict_Next
=
dlsym
(
py_handle
,
"PyDict_Next"
)
PyDict_GetItem
=
dlsym
(
py_handle
,
"PyDict_GetItem"
)
PyDict_GetItemString
=
dlsym
(
py_handle
,
"PyDict_GetItemString"
)
PyDict_SetItem
=
dlsym
(
py_handle
,
"PyDict_SetItem"
)
PyDict_Size
=
dlsym
(
py_handle
,
"PyDict_Size"
)
PySet_Add
=
dlsym
(
py_handle
,
"PySet_Add"
)
PySet_New
=
dlsym
(
py_handle
,
"PySet_New"
)
PyTuple_New
=
dlsym
(
py_handle
,
"PyTuple_New"
)
PyTuple_Size
=
dlsym
(
py_handle
,
"PyTuple_Size"
)
PyTuple_GetItem
=
dlsym
(
py_handle
,
"PyTuple_GetItem"
)
PyTuple_SetItem
=
dlsym
(
py_handle
,
"PyTuple_SetItem"
)
PyUnicode_AsEncodedString
=
dlsym
(
py_handle
,
"PyUnicode_AsEncodedString"
)
PyUnicode_DecodeFSDefaultAndSize
=
dlsym
(
py_handle
,
"PyUnicode_DecodeFSDefaultAndSize"
)
PyUnicode_FromString
=
dlsym
(
py_handle
,
"PyUnicode_FromString"
)
PyComplex_FromDoubles
=
dlsym
(
py_handle
,
"PyComplex_FromDoubles"
)
PyComplex_RealAsDouble
=
dlsym
(
py_handle
,
"PyComplex_RealAsDouble"
)
PyComplex_ImagAsDouble
=
dlsym
(
py_handle
,
"PyComplex_ImagAsDouble"
)
PyIter_Next
=
dlsym
(
py_handle
,
"PyIter_Next"
)
PySlice_New
=
dlsym
(
py_handle
,
"PySlice_New"
)
PySlice_Unpack
=
dlsym
(
py_handle
,
"PySlice_Unpack"
)
PyCapsule_New
=
dlsym
(
py_handle
,
"PyCapsule_New"
)
PyCapsule_GetPointer
=
dlsym
(
py_handle
,
"PyCapsule_GetPointer"
)
PyNumber_Add
=
dlsym
(
py_handle
,
"PyNumber_Add"
)
PyNumber_Subtract
=
dlsym
(
py_handle
,
"PyNumber_Subtract"
)
PyNumber_Multiply
=
dlsym
(
py_handle
,
"PyNumber_Multiply"
)
PyNumber_MatrixMultiply
=
dlsym
(
py_handle
,
"PyNumber_MatrixMultiply"
)
PyNumber_FloorDivide
=
dlsym
(
py_handle
,
"PyNumber_FloorDivide"
)
PyNumber_TrueDivide
=
dlsym
(
py_handle
,
"PyNumber_TrueDivide"
)
PyNumber_Remainder
=
dlsym
(
py_handle
,
"PyNumber_Remainder"
)
PyNumber_Divmod
=
dlsym
(
py_handle
,
"PyNumber_Divmod"
)
PyNumber_Power
=
dlsym
(
py_handle
,
"PyNumber_Power"
)
PyNumber_Negative
=
dlsym
(
py_handle
,
"PyNumber_Negative"
)
PyNumber_Positive
=
dlsym
(
py_handle
,
"PyNumber_Positive"
)
PyNumber_Absolute
=
dlsym
(
py_handle
,
"PyNumber_Absolute"
)
PyNumber_Invert
=
dlsym
(
py_handle
,
"PyNumber_Invert"
)
PyNumber_Lshift
=
dlsym
(
py_handle
,
"PyNumber_Lshift"
)
PyNumber_Rshift
=
dlsym
(
py_handle
,
"PyNumber_Rshift"
)
PyNumber_And
=
dlsym
(
py_handle
,
"PyNumber_And"
)
PyNumber_Xor
=
dlsym
(
py_handle
,
"PyNumber_Xor"
)
PyNumber_Or
=
dlsym
(
py_handle
,
"PyNumber_Or"
)
PyNumber_InPlaceAdd
=
dlsym
(
py_handle
,
"PyNumber_InPlaceAdd"
)
PyNumber_InPlaceSubtract
=
dlsym
(
py_handle
,
"PyNumber_InPlaceSubtract"
)
PyNumber_InPlaceMultiply
=
dlsym
(
py_handle
,
"PyNumber_InPlaceMultiply"
)
PyNumber_InPlaceMatrixMultiply
=
dlsym
(
py_handle
,
"PyNumber_InPlaceMatrixMultiply"
)
PyNumber_InPlaceFloorDivide
=
dlsym
(
py_handle
,
"PyNumber_InPlaceFloorDivide"
)
PyNumber_InPlaceTrueDivide
=
dlsym
(
py_handle
,
"PyNumber_InPlaceTrueDivide"
)
PyNumber_InPlaceRemainder
=
dlsym
(
py_handle
,
"PyNumber_InPlaceRemainder"
)
PyNumber_InPlacePower
=
dlsym
(
py_handle
,
"PyNumber_InPlacePower"
)
PyNumber_InPlaceLshift
=
dlsym
(
py_handle
,
"PyNumber_InPlaceLshift"
)
PyNumber_InPlaceRshift
=
dlsym
(
py_handle
,
"PyNumber_InPlaceRshift"
)
PyNumber_InPlaceAnd
=
dlsym
(
py_handle
,
"PyNumber_InPlaceAnd"
)
PyNumber_InPlaceXor
=
dlsym
(
py_handle
,
"PyNumber_InPlaceXor"
)
PyNumber_InPlaceOr
=
dlsym
(
py_handle
,
"PyNumber_InPlaceOr"
)
PyNumber_Long
=
dlsym
(
py_handle
,
"PyNumber_Long"
)
PyNumber_Float
=
dlsym
(
py_handle
,
"PyNumber_Float"
)
PyNumber_Index
=
dlsym
(
py_handle
,
"PyNumber_Index"
)
PyObject_Call
=
dlsym
(
py_handle
,
"PyObject_Call"
)
PyObject_CallNoArgs
=
dlsym
(
py_handle
,
"PyObject_CallNoArgs"
)
PyObject_CallOneArg
=
dlsym
(
py_handle
,
"PyObject_CallOneArg"
)
PyObject_GetAttr
=
dlsym
(
py_handle
,
"PyObject_GetAttr"
)
PyObject_GetAttrString
=
dlsym
(
py_handle
,
"PyObject_GetAttrString"
)
PyObject_GetIter
=
dlsym
(
py_handle
,
"PyObject_GetIter"
)
PyObject_HasAttrString
=
dlsym
(
py_handle
,
"PyObject_HasAttrString"
)
PyObject_IsTrue
=
dlsym
(
py_handle
,
"PyObject_IsTrue"
)
PyObject_Length
=
dlsym
(
py_handle
,
"PyObject_Length"
)
PyObject_LengthHint
=
dlsym
(
py_handle
,
"PyObject_LengthHint"
)
PyObject_SetAttrString
=
dlsym
(
py_handle
,
"PyObject_SetAttrString"
)
PyObject_Str
=
dlsym
(
py_handle
,
"PyObject_Str"
)
PyObject_Repr
=
dlsym
(
py_handle
,
"PyObject_Repr"
)
PyObject_Hash
=
dlsym
(
py_handle
,
"PyObject_Hash"
)
PyObject_GetItem
=
dlsym
(
py_handle
,
"PyObject_GetItem"
)
PyObject_SetItem
=
dlsym
(
py_handle
,
"PyObject_SetItem"
)
PyObject_DelItem
=
dlsym
(
py_handle
,
"PyObject_DelItem"
)
PyObject_RichCompare
=
dlsym
(
py_handle
,
"PyObject_RichCompare"
)
PyObject_IsInstance
=
dlsym
(
py_handle
,
"PyObject_IsInstance"
)
PyErr_Fetch
=
dlsym
(
py_handle
,
"PyErr_Fetch"
)
PyErr_NormalizeException
=
dlsym
(
py_handle
,
"PyErr_NormalizeException"
)
PyErr_SetString
=
dlsym
(
py_handle
,
"PyErr_SetString"
)
Py_None
=
dlsym
(
py_handle
,
"_Py_NoneStruct"
)
Py_True
=
dlsym
(
py_handle
,
"_Py_TrueStruct"
)
Py_False
=
dlsym
(
py_handle
,
"_Py_FalseStruct"
)
Py_Ellipsis
=
dlsym
(
py_handle
,
"_Py_EllipsisObject"
)
Py_NotImplemented
=
dlsym
(
py_handle
,
"_Py_NotImplementedStruct"
)
PyLong_Type
=
dlsym
(
py_handle
,
"PyLong_Type"
)
PyFloat_Type
=
dlsym
(
py_handle
,
"PyFloat_Type"
)
PyBool_Type
=
dlsym
(
py_handle
,
"PyBool_Type"
)
PyUnicode_Type
=
dlsym
(
py_handle
,
"PyUnicode_Type"
)
PyBytes_Type
=
dlsym
(
py_handle
,
"PyBytes_Type"
)
PyComplex_Type
=
dlsym
(
py_handle
,
"PyComplex_Type"
)
PyList_Type
=
dlsym
(
py_handle
,
"PyList_Type"
)
PyDict_Type
=
dlsym
(
py_handle
,
"PyDict_Type"
)
PySet_Type
=
dlsym
(
py_handle
,
"PySet_Type"
)
PyTuple_Type
=
dlsym
(
py_handle
,
"PyTuple_Type"
)
PySlice_Type
=
dlsym
(
py_handle
,
"PySlice_Type"
)
PyCapsule_Type
=
dlsym
(
py_handle
,
"PyCapsule_Type"
)
PyExc_BaseException
=
Ptr
[
cobj
](
dlsym
(
py_handle
,
"PyExc_BaseException"
,
cobj
))[
0
]
PyExc_Exception
=
Ptr
[
cobj
](
dlsym
(
py_handle
,
"PyExc_Exception"
,
cobj
))[
0
]
PyExc_NameError
=
Ptr
[
cobj
](
dlsym
(
py_handle
,
"PyExc_NameError"
,
cobj
))[
0
]
PyExc_OSError
=
Ptr
[
cobj
](
dlsym
(
py_handle
,
"PyExc_OSError"
,
cobj
))[
0
]
PyExc_IOError
=
Ptr
[
cobj
](
dlsym
(
py_handle
,
"PyExc_IOError"
,
cobj
))[
0
]
PyExc_ValueError
=
Ptr
[
cobj
](
dlsym
(
py_handle
,
"PyExc_ValueError"
,
cobj
))[
0
]
PyExc_LookupError
=
Ptr
[
cobj
](
dlsym
(
py_handle
,
"PyExc_LookupError"
,
cobj
))[
0
]
PyExc_IndexError
=
Ptr
[
cobj
](
dlsym
(
py_handle
,
"PyExc_IndexError"
,
cobj
))[
0
]
PyExc_KeyError
=
Ptr
[
cobj
](
dlsym
(
py_handle
,
"PyExc_KeyError"
,
cobj
))[
0
]
PyExc_TypeError
=
Ptr
[
cobj
](
dlsym
(
py_handle
,
"PyExc_TypeError"
,
cobj
))[
0
]
PyExc_ArithmeticError
=
Ptr
[
cobj
](
dlsym
(
py_handle
,
"PyExc_ArithmeticError"
,
cobj
))[
0
]
PyExc_ZeroDivisionError
=
Ptr
[
cobj
](
dlsym
(
py_handle
,
"PyExc_ZeroDivisionError"
,
cobj
))[
0
]
PyExc_OverflowError
=
Ptr
[
cobj
](
dlsym
(
py_handle
,
"PyExc_OverflowError"
,
cobj
))[
0
]
PyExc_AttributeError
=
Ptr
[
cobj
](
dlsym
(
py_handle
,
"PyExc_AttributeError"
,
cobj
))[
0
]
PyExc_RuntimeError
=
Ptr
[
cobj
](
dlsym
(
py_handle
,
"PyExc_RuntimeError"
,
cobj
))[
0
]
PyExc_NotImplementedError
=
Ptr
[
cobj
](
dlsym
(
py_handle
,
"PyExc_NotImplementedError"
,
cobj
))[
0
]
PyExc_StopIteration
=
Ptr
[
cobj
](
dlsym
(
py_handle
,
"PyExc_StopIteration"
,
cobj
))[
0
]
PyExc_AssertionError
=
Ptr
[
cobj
](
dlsym
(
py_handle
,
"PyExc_AssertionError"
,
cobj
))[
0
]
PyExc_EOFError
=
Ptr
[
cobj
](
dlsym
(
py_handle
,
"PyExc_EOFError"
,
cobj
))[
0
]
PyExc_SystemExit
=
Ptr
[
cobj
](
dlsym
(
py_handle
,
"PyExc_SystemExit"
,
cobj
))[
0
]
def
init_handles_static
():
from
C
import
Py_DecRef
(
cobj
)
as
_Py_DecRef
from
C
import
Py_IncRef
(
cobj
)
as
_Py_IncRef
from
C
import
Py_Initialize
()
as
_Py_Initialize
from
C
import
PyImport_AddModule
(
cobj
)
-
>
cobj
as
_PyImport_AddModule
from
C
import
PyImport_AddModuleObject
(
cobj
)
-
>
cobj
as
_PyImport_AddModuleObject
from
C
import
PyImport_ImportModule
(
cobj
)
-
>
cobj
as
_PyImport_ImportModule
from
C
import
PyRun_SimpleString
(
cobj
)
as
_PyRun_SimpleString
from
C
import
PyEval_GetGlobals
()
-
>
cobj
as
_PyEval_GetGlobals
from
C
import
PyEval_GetBuiltins
()
-
>
cobj
as
_PyEval_GetBuiltins
from
C
import
PyOS_setsig
(
i32
,
cobj
)
-
>
cobj
as
_PyOS_setsig
from
C
import
PyLong_AsLong
(
cobj
)
-
>
int
as
_PyLong_AsLong
from
C
import
PyLong_FromLong
(
int
)
-
>
cobj
as
_PyLong_FromLong
from
C
import
PyFloat_AsDouble
(
cobj
)
-
>
float
as
_PyFloat_AsDouble
from
C
import
PyFloat_FromDouble
(
float
)
-
>
cobj
as
_PyFloat_FromDouble
from
C
import
PyBool_FromLong
(
int
)
-
>
cobj
as
_PyBool_FromLong
from
C
import
PyBytes_AsString
(
cobj
)
-
>
cobj
as
_PyBytes_AsString
from
C
import
PyBytes_Size
(
cobj
)
-
>
int
as
_PyBytes_Size
from
C
import
PyList_New
(
int
)
-
>
cobj
as
_PyList_New
from
C
import
PyList_Size
(
cobj
)
-
>
int
as
_PyList_Size
from
C
import
PyList_GetItem
(
cobj
,
int
)
-
>
cobj
as
_PyList_GetItem
from
C
import
PyList_SetItem
(
cobj
,
int
,
cobj
)
-
>
cobj
as
_PyList_SetItem
from
C
import
PyDict_New
()
-
>
cobj
as
_PyDict_New
from
C
import
PyDict_Next
(
cobj
,
Ptr
[
int
],
Ptr
[
cobj
],
Ptr
[
cobj
])
-
>
int
as
_PyDict_Next
from
C
import
PyDict_GetItem
(
cobj
,
cobj
)
-
>
cobj
as
_PyDict_GetItem
from
C
import
PyDict_GetItemString
(
cobj
,
cobj
)
-
>
cobj
as
_PyDict_GetItemString
from
C
import
PyDict_SetItem
(
cobj
,
cobj
,
cobj
)
-
>
cobj
as
_PyDict_SetItem
from
C
import
PyDict_Size
(
cobj
)
-
>
int
as
_PyDict_Size
from
C
import
PySet_Add
(
cobj
,
cobj
)
-
>
cobj
as
_PySet_Add
from
C
import
PySet_New
(
cobj
)
-
>
cobj
as
_PySet_New
from
C
import
PyTuple_New
(
int
)
-
>
cobj
as
_PyTuple_New
from
C
import
PyTuple_Size
(
cobj
)
-
>
int
as
_PyTuple_Size
from
C
import
PyTuple_GetItem
(
cobj
,
int
)
-
>
cobj
as
_PyTuple_GetItem
from
C
import
PyTuple_SetItem
(
cobj
,
int
,
cobj
)
-
>
i32
as
_PyTuple_SetItem
from
C
import
PyUnicode_AsEncodedString
(
cobj
,
cobj
,
cobj
)
-
>
cobj
as
_PyUnicode_AsEncodedString
from
C
import
PyUnicode_DecodeFSDefaultAndSize
(
cobj
,
int
)
-
>
cobj
as
_PyUnicode_DecodeFSDefaultAndSize
from
C
import
PyUnicode_FromString
(
cobj
)
-
>
cobj
as
_PyUnicode_FromString
from
C
import
PyComplex_FromDoubles
(
float
,
float
)
-
>
cobj
as
_PyComplex_FromDoubles
from
C
import
PyComplex_RealAsDouble
(
cobj
)
-
>
float
as
_PyComplex_RealAsDouble
from
C
import
PyComplex_ImagAsDouble
(
cobj
)
-
>
float
as
_PyComplex_ImagAsDouble
from
C
import
PyIter_Next
(
cobj
)
-
>
cobj
as
_PyIter_Next
from
C
import
PySlice_New
(
cobj
,
cobj
,
cobj
)
-
>
cobj
as
_PySlice_New
from
C
import
PySlice_Unpack
(
cobj
,
Ptr
[
int
],
Ptr
[
int
],
Ptr
[
int
])
-
>
int
as
_PySlice_Unpack
from
C
import
PyCapsule_New
(
cobj
,
cobj
,
cobj
)
-
>
cobj
as
_PyCapsule_New
from
C
import
PyCapsule_GetPointer
(
cobj
,
cobj
)
-
>
cobj
as
_PyCapsule_GetPointer
from
C
import
PyNumber_Add
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_Add
from
C
import
PyNumber_Subtract
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_Subtract
from
C
import
PyNumber_Multiply
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_Multiply
from
C
import
PyNumber_MatrixMultiply
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_MatrixMultiply
from
C
import
PyNumber_FloorDivide
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_FloorDivide
from
C
import
PyNumber_TrueDivide
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_TrueDivide
from
C
import
PyNumber_Remainder
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_Remainder
from
C
import
PyNumber_Divmod
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_Divmod
from
C
import
PyNumber_Power
(
cobj
,
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_Power
from
C
import
PyNumber_Negative
(
cobj
)
-
>
cobj
as
_PyNumber_Negative
from
C
import
PyNumber_Positive
(
cobj
)
-
>
cobj
as
_PyNumber_Positive
from
C
import
PyNumber_Absolute
(
cobj
)
-
>
cobj
as
_PyNumber_Absolute
from
C
import
PyNumber_Invert
(
cobj
)
-
>
cobj
as
_PyNumber_Invert
from
C
import
PyNumber_Lshift
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_Lshift
from
C
import
PyNumber_Rshift
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_Rshift
from
C
import
PyNumber_And
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_And
from
C
import
PyNumber_Xor
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_Xor
from
C
import
PyNumber_Or
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_Or
from
C
import
PyNumber_InPlaceAdd
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_InPlaceAdd
from
C
import
PyNumber_InPlaceSubtract
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_InPlaceSubtract
from
C
import
PyNumber_InPlaceMultiply
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_InPlaceMultiply
from
C
import
PyNumber_InPlaceMatrixMultiply
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_InPlaceMatrixMultiply
from
C
import
PyNumber_InPlaceFloorDivide
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_InPlaceFloorDivide
from
C
import
PyNumber_InPlaceTrueDivide
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_InPlaceTrueDivide
from
C
import
PyNumber_InPlaceRemainder
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_InPlaceRemainder
from
C
import
PyNumber_InPlacePower
(
cobj
,
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_InPlacePower
from
C
import
PyNumber_InPlaceLshift
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_InPlaceLshift
from
C
import
PyNumber_InPlaceRshift
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_InPlaceRshift
from
C
import
PyNumber_InPlaceAnd
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_InPlaceAnd
from
C
import
PyNumber_InPlaceXor
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_InPlaceXor
from
C
import
PyNumber_InPlaceOr
(
cobj
,
cobj
)
-
>
cobj
as
_PyNumber_InPlaceOr
from
C
import
PyNumber_Long
(
cobj
)
-
>
cobj
as
_PyNumber_Long
from
C
import
PyNumber_Float
(
cobj
)
-
>
cobj
as
_PyNumber_Float
from
C
import
PyNumber_Index
(
cobj
)
-
>
cobj
as
_PyNumber_Index
from
C
import
PyObject_Call
(
cobj
,
cobj
,
cobj
)
-
>
cobj
as
_PyObject_Call
from
C
import
PyObject_CallNoArgs
(
cobj
)
-
>
cobj
as
_PyObject_CallNoArgs
from
C
import
PyObject_CallOneArg
(
cobj
,
cobj
)
-
>
cobj
as
_PyObject_CallOneArg
from
C
import
PyObject_GetAttr
(
cobj
,
cobj
)
-
>
cobj
as
_PyObject_GetAttr
from
C
import
PyObject_GetAttrString
(
cobj
,
cobj
)
-
>
cobj
as
_PyObject_GetAttrString
from
C
import
PyObject_GetIter
(
cobj
)
-
>
cobj
as
_PyObject_GetIter
from
C
import
PyObject_HasAttrString
(
cobj
,
cobj
)
-
>
int
as
_PyObject_HasAttrString
from
C
import
PyObject_IsTrue
(
cobj
)
-
>
i32
as
_PyObject_IsTrue
from
C
import
PyObject_Length
(
cobj
)
-
>
int
as
_PyObject_Length
from
C
import
PyObject_LengthHint
(
cobj
,
int
)
-
>
int
as
_PyObject_LengthHint
from
C
import
PyObject_SetAttrString
(
cobj
,
cobj
,
cobj
)
-
>
cobj
as
_PyObject_SetAttrString
from
C
import
PyObject_Str
(
cobj
)
-
>
cobj
as
_PyObject_Str
from
C
import
PyObject_Repr
(
cobj
)
-
>
cobj
as
_PyObject_Repr
from
C
import
PyObject_Hash
(
cobj
)
-
>
int
as
_PyObject_Hash
from
C
import
PyObject_GetItem
(
cobj
,
cobj
)
-
>
cobj
as
_PyObject_GetItem
from
C
import
PyObject_SetItem
(
cobj
,
cobj
,
cobj
)
-
>
int
as
_PyObject_SetItem
from
C
import
PyObject_DelItem
(
cobj
,
cobj
)
-
>
int
as
_PyObject_DelItem
from
C
import
PyObject_RichCompare
(
cobj
,
cobj
,
i32
)
-
>
cobj
as
_PyObject_RichCompare
from
C
import
PyObject_IsInstance
(
cobj
,
cobj
)
-
>
i32
as
_PyObject_IsInstance
from
C
import
PyErr_Fetch
(
Ptr
[
cobj
],
Ptr
[
cobj
],
Ptr
[
cobj
])
as
_PyErr_Fetch
from
C
import
PyErr_NormalizeException
(
Ptr
[
cobj
],
Ptr
[
cobj
],
Ptr
[
cobj
])
as
_PyErr_NormalizeException
from
C
import
PyErr_SetString
(
cobj
,
cobj
)
as
_PyErr_SetString
from
C
import
_Py_NoneStruct
:
cobj
from
C
import
_Py_TrueStruct
:
cobj
from
C
import
_Py_FalseStruct
:
cobj
from
C
import
_Py_EllipsisObject
:
cobj
from
C
import
_Py_NotImplementedStruct
:
cobj
from
C
import
PyLong_Type
:
cobj
as
_PyLong_Type
from
C
import
PyFloat_Type
:
cobj
as
_PyFloat_Type
from
C
import
PyBool_Type
:
cobj
as
_PyBool_Type
from
C
import
PyUnicode_Type
:
cobj
as
_PyUnicode_Type
from
C
import
PyBytes_Type
:
cobj
as
_PyBytes_Type
from
C
import
PyComplex_Type
:
cobj
as
_PyComplex_Type
from
C
import
PyList_Type
:
cobj
as
_PyList_Type
from
C
import
PyDict_Type
:
cobj
as
_PyDict_Type
from
C
import
PySet_Type
:
cobj
as
_PySet_Type
from
C
import
PyTuple_Type
:
cobj
as
_PyTuple_Type
from
C
import
PySlice_Type
:
cobj
as
_PySlice_Type
from
C
import
PyCapsule_Type
:
cobj
as
_PyCapsule_Type
from
C
import
PyExc_BaseException
:
cobj
as
_PyExc_BaseException
from
C
import
PyExc_Exception
:
cobj
as
_PyExc_Exception
from
C
import
PyExc_NameError
:
cobj
as
_PyExc_NameError
from
C
import
PyExc_OSError
:
cobj
as
_PyExc_OSError
from
C
import
PyExc_IOError
:
cobj
as
_PyExc_IOError
from
C
import
PyExc_ValueError
:
cobj
as
_PyExc_ValueError
from
C
import
PyExc_LookupError
:
cobj
as
_PyExc_LookupError
from
C
import
PyExc_IndexError
:
cobj
as
_PyExc_IndexError
from
C
import
PyExc_KeyError
:
cobj
as
_PyExc_KeyError
from
C
import
PyExc_TypeError
:
cobj
as
_PyExc_TypeError
from
C
import
PyExc_ArithmeticError
:
cobj
as
_PyExc_ArithmeticError
from
C
import
PyExc_ZeroDivisionError
:
cobj
as
_PyExc_ZeroDivisionError
from
C
import
PyExc_OverflowError
:
cobj
as
_PyExc_OverflowError
from
C
import
PyExc_AttributeError
:
cobj
as
_PyExc_AttributeError
from
C
import
PyExc_RuntimeError
:
cobj
as
_PyExc_RuntimeError
from
C
import
PyExc_NotImplementedError
:
cobj
as
_PyExc_NotImplementedError
from
C
import
PyExc_StopIteration
:
cobj
as
_PyExc_StopIteration
from
C
import
PyExc_AssertionError
:
cobj
as
_PyExc_AssertionError
from
C
import
PyExc_EOFError
:
cobj
as
_PyExc_EOFError
from
C
import
PyExc_SystemExit
:
cobj
as
_PyExc_SystemExit
global
Py_DecRef
global
Py_IncRef
global
Py_Initialize
global
PyImport_AddModule
global
PyImport_AddModuleObject
global
PyImport_ImportModule
global
PyRun_SimpleString
global
PyEval_GetGlobals
global
PyEval_GetBuiltins
global
PyOS_setsig
global
PyLong_AsLong
global
PyLong_FromLong
global
PyFloat_AsDouble
global
PyFloat_FromDouble
global
PyBool_FromLong
global
PyBytes_AsString
global
PyBytes_Size
global
PyList_New
global
PyList_Size
global
PyList_GetItem
global
PyList_SetItem
global
PyDict_New
global
PyDict_Next
global
PyDict_GetItem
global
PyDict_GetItemString
global
PyDict_SetItem
global
PyDict_Size
global
PySet_Add
global
PySet_New
global
PyTuple_New
global
PyTuple_Size
global
PyTuple_GetItem
global
PyTuple_SetItem
global
PyUnicode_AsEncodedString
global
PyUnicode_DecodeFSDefaultAndSize
global
PyUnicode_FromString
global
PyComplex_FromDoubles
global
PyComplex_RealAsDouble
global
PyComplex_ImagAsDouble
global
PyIter_Next
global
PySlice_New
global
PySlice_Unpack
global
PyCapsule_New
global
PyCapsule_GetPointer
global
PyNumber_Add
global
PyNumber_Subtract
global
PyNumber_Multiply
global
PyNumber_MatrixMultiply
global
PyNumber_FloorDivide
global
PyNumber_TrueDivide
global
PyNumber_Remainder
global
PyNumber_Divmod
global
PyNumber_Power
global
PyNumber_Negative
global
PyNumber_Positive
global
PyNumber_Absolute
global
PyNumber_Invert
global
PyNumber_Lshift
global
PyNumber_Rshift
global
PyNumber_And
global
PyNumber_Xor
global
PyNumber_Or
global
PyNumber_InPlaceAdd
global
PyNumber_InPlaceSubtract
global
PyNumber_InPlaceMultiply
global
PyNumber_InPlaceMatrixMultiply
global
PyNumber_InPlaceFloorDivide
global
PyNumber_InPlaceTrueDivide
global
PyNumber_InPlaceRemainder
global
PyNumber_InPlacePower
global
PyNumber_InPlaceLshift
global
PyNumber_InPlaceRshift
global
PyNumber_InPlaceAnd
global
PyNumber_InPlaceXor
global
PyNumber_InPlaceOr
global
PyNumber_Long
global
PyNumber_Float
global
PyNumber_Index
global
PyObject_Call
global
PyObject_CallNoArgs
global
PyObject_CallOneArg
global
PyObject_GetAttr
global
PyObject_GetAttrString
global
PyObject_GetIter
global
PyObject_HasAttrString
global
PyObject_IsTrue
global
PyObject_Length
global
PyObject_LengthHint
global
PyObject_SetAttrString
global
PyObject_Str
global
PyObject_Repr
global
PyObject_Hash
global
PyObject_GetItem
global
PyObject_SetItem
global
PyObject_DelItem
global
PyObject_RichCompare
global
PyObject_IsInstance
global
PyErr_Fetch
global
PyErr_NormalizeException
global
PyErr_SetString
global
Py_None
global
Py_True
global
Py_False
global
Py_Ellipsis
global
Py_NotImplemented
global
PyLong_Type
global
PyFloat_Type
global
PyBool_Type
global
PyUnicode_Type
global
PyBytes_Type
global
PyComplex_Type
global
PyList_Type
global
PyDict_Type
global
PySet_Type
global
PyTuple_Type
global
PySlice_Type
global
PyCapsule_Type
global
PyExc_BaseException
global
PyExc_Exception
global
PyExc_NameError
global
PyExc_OSError
global
PyExc_IOError
global
PyExc_ValueError
global
PyExc_LookupError
global
PyExc_IndexError
global
PyExc_KeyError
global
PyExc_TypeError
global
PyExc_ArithmeticError
global
PyExc_ZeroDivisionError
global
PyExc_OverflowError
global
PyExc_AttributeError
global
PyExc_RuntimeError
global
PyExc_NotImplementedError
global
PyExc_StopIteration
global
PyExc_AssertionError
global
PyExc_EOFError
global
PyExc_SystemExit
Py_DecRef
=
_Py_DecRef
Py_IncRef
=
_Py_IncRef
Py_Initialize
=
_Py_Initialize
PyImport_AddModule
=
_PyImport_AddModule
PyImport_AddModuleObject
=
_PyImport_AddModuleObject
PyImport_ImportModule
=
_PyImport_ImportModule
PyRun_SimpleString
=
_PyRun_SimpleString
PyEval_GetGlobals
=
_PyEval_GetGlobals
PyEval_GetBuiltins
=
_PyEval_GetBuiltins
PyOS_setsig
=
_PyOS_setsig
PyLong_AsLong
=
_PyLong_AsLong
PyLong_FromLong
=
_PyLong_FromLong
PyFloat_AsDouble
=
_PyFloat_AsDouble
PyFloat_FromDouble
=
_PyFloat_FromDouble
PyBool_FromLong
=
_PyBool_FromLong
PyBytes_AsString
=
_PyBytes_AsString
PyBytes_Size
=
_PyBytes_Size
PyList_New
=
_PyList_New
PyList_Size
=
_PyList_Size
PyList_GetItem
=
_PyList_GetItem
PyList_SetItem
=
_PyList_SetItem
PyDict_New
=
_PyDict_New
PyDict_Next
=
_PyDict_Next
PyDict_GetItem
=
_PyDict_GetItem
PyDict_GetItemString
=
_PyDict_GetItemString
PyDict_SetItem
=
_PyDict_SetItem
PyDict_Size
=
_PyDict_Size
PySet_Add
=
_PySet_Add
PySet_New
=
_PySet_New
PyTuple_New
=
_PyTuple_New
PyTuple_Size
=
_PyTuple_Size
PyTuple_GetItem
=
_PyTuple_GetItem
PyTuple_SetItem
=
_PyTuple_SetItem
PyUnicode_AsEncodedString
=
_PyUnicode_AsEncodedString
PyUnicode_DecodeFSDefaultAndSize
=
_PyUnicode_DecodeFSDefaultAndSize
PyUnicode_FromString
=
_PyUnicode_FromString
PyComplex_FromDoubles
=
_PyComplex_FromDoubles
PyComplex_RealAsDouble
=
_PyComplex_RealAsDouble
PyComplex_ImagAsDouble
=
_PyComplex_ImagAsDouble
PyIter_Next
=
_PyIter_Next
PySlice_New
=
_PySlice_New
PySlice_Unpack
=
_PySlice_Unpack
PyCapsule_New
=
_PyCapsule_New
PyCapsule_GetPointer
=
_PyCapsule_GetPointer
PyNumber_Add
=
_PyNumber_Add
PyNumber_Subtract
=
_PyNumber_Subtract
PyNumber_Multiply
=
_PyNumber_Multiply
PyNumber_MatrixMultiply
=
_PyNumber_MatrixMultiply
PyNumber_FloorDivide
=
_PyNumber_FloorDivide
PyNumber_TrueDivide
=
_PyNumber_TrueDivide
PyNumber_Remainder
=
_PyNumber_Remainder
PyNumber_Divmod
=
_PyNumber_Divmod
PyNumber_Power
=
_PyNumber_Power
PyNumber_Negative
=
_PyNumber_Negative
PyNumber_Positive
=
_PyNumber_Positive
PyNumber_Absolute
=
_PyNumber_Absolute
PyNumber_Invert
=
_PyNumber_Invert
PyNumber_Lshift
=
_PyNumber_Lshift
PyNumber_Rshift
=
_PyNumber_Rshift
PyNumber_And
=
_PyNumber_And
PyNumber_Xor
=
_PyNumber_Xor
PyNumber_Or
=
_PyNumber_Or
PyNumber_InPlaceAdd
=
_PyNumber_InPlaceAdd
PyNumber_InPlaceSubtract
=
_PyNumber_InPlaceSubtract
PyNumber_InPlaceMultiply
=
_PyNumber_InPlaceMultiply
PyNumber_InPlaceMatrixMultiply
=
_PyNumber_InPlaceMatrixMultiply
PyNumber_InPlaceFloorDivide
=
_PyNumber_InPlaceFloorDivide
PyNumber_InPlaceTrueDivide
=
_PyNumber_InPlaceTrueDivide
PyNumber_InPlaceRemainder
=
_PyNumber_InPlaceRemainder
PyNumber_InPlacePower
=
_PyNumber_InPlacePower
PyNumber_InPlaceLshift
=
_PyNumber_InPlaceLshift
PyNumber_InPlaceRshift
=
_PyNumber_InPlaceRshift
PyNumber_InPlaceAnd
=
_PyNumber_InPlaceAnd
PyNumber_InPlaceXor
=
_PyNumber_InPlaceXor
PyNumber_InPlaceOr
=
_PyNumber_InPlaceOr
PyNumber_Long
=
_PyNumber_Long
PyNumber_Float
=
_PyNumber_Float
PyNumber_Index
=
_PyNumber_Index
PyObject_Call
=
_PyObject_Call
PyObject_CallNoArgs
=
_PyObject_CallNoArgs
PyObject_CallOneArg
=
_PyObject_CallOneArg
PyObject_GetAttr
=
_PyObject_GetAttr
PyObject_GetAttrString
=
_PyObject_GetAttrString
PyObject_GetIter
=
_PyObject_GetIter
PyObject_HasAttrString
=
_PyObject_HasAttrString
PyObject_IsTrue
=
_PyObject_IsTrue
PyObject_Length
=
_PyObject_Length
PyObject_LengthHint
=
_PyObject_LengthHint
PyObject_SetAttrString
=
_PyObject_SetAttrString
PyObject_Str
=
_PyObject_Str
PyObject_Repr
=
_PyObject_Repr
PyObject_Hash
=
_PyObject_Hash
PyObject_GetItem
=
_PyObject_GetItem
PyObject_SetItem
=
_PyObject_SetItem
PyObject_DelItem
=
_PyObject_DelItem
PyObject_RichCompare
=
_PyObject_RichCompare
PyObject_IsInstance
=
_PyObject_IsInstance
PyErr_Fetch
=
_PyErr_Fetch
PyErr_NormalizeException
=
_PyErr_NormalizeException
PyErr_SetString
=
_PyErr_SetString
Py_None
=
__ptr__
(
_Py_NoneStruct
).
as_byte
()
Py_True
=
__ptr__
(
_Py_TrueStruct
).
as_byte
()
Py_False
=
__ptr__
(
_Py_FalseStruct
).
as_byte
()
Py_Ellipsis
=
__ptr__
(
_Py_EllipsisObject
).
as_byte
()
Py_NotImplemented
=
__ptr__
(
_Py_NotImplementedStruct
).
as_byte
()
PyLong_Type
=
__ptr__
(
_PyLong_Type
).
as_byte
()
PyFloat_Type
=
__ptr__
(
_PyFloat_Type
).
as_byte
()
PyBool_Type
=
__ptr__
(
_PyBool_Type
).
as_byte
()
PyUnicode_Type
=
__ptr__
(
_PyUnicode_Type
).
as_byte
()
PyBytes_Type
=
__ptr__
(
_PyBytes_Type
).
as_byte
()
PyComplex_Type
=
__ptr__
(
_PyComplex_Type
).
as_byte
()
PyList_Type
=
__ptr__
(
_PyList_Type
).
as_byte
()
PyDict_Type
=
__ptr__
(
_PyDict_Type
).
as_byte
()
PySet_Type
=
__ptr__
(
_PySet_Type
).
as_byte
()
PyTuple_Type
=
__ptr__
(
_PyTuple_Type
).
as_byte
()
PySlice_Type
=
__ptr__
(
_PySlice_Type
).
as_byte
()
PyCapsule_Type
=
__ptr__
(
_PyCapsule_Type
).
as_byte
()
PyExc_BaseException
=
_PyExc_BaseException
PyExc_Exception
=
_PyExc_Exception
PyExc_NameError
=
_PyExc_NameError
PyExc_OSError
=
_PyExc_OSError
PyExc_IOError
=
_PyExc_IOError
PyExc_ValueError
=
_PyExc_ValueError
PyExc_LookupError
=
_PyExc_LookupError
PyExc_IndexError
=
_PyExc_IndexError
PyExc_KeyError
=
_PyExc_KeyError
PyExc_TypeError
=
_PyExc_TypeError
PyExc_ArithmeticError
=
_PyExc_ArithmeticError
PyExc_ZeroDivisionError
=
_PyExc_ZeroDivisionError
PyExc_OverflowError
=
_PyExc_OverflowError
PyExc_AttributeError
=
_PyExc_AttributeError
PyExc_RuntimeError
=
_PyExc_RuntimeError
PyExc_NotImplementedError
=
_PyExc_NotImplementedError
PyExc_StopIteration
=
_PyExc_StopIteration
PyExc_AssertionError
=
_PyExc_AssertionError
PyExc_EOFError
=
_PyExc_EOFError
PyExc_SystemExit
=
_PyExc_SystemExit
def
init_error_py_types
():
BaseException
.
_pytype
=
PyExc_BaseException
Exception
.
_pytype
=
PyExc_Exception
NameError
.
_pytype
=
PyExc_NameError
OSError
.
_pytype
=
PyExc_OSError
IOError
.
_pytype
=
PyExc_IOError
ValueError
.
_pytype
=
PyExc_ValueError
LookupError
.
_pytype
=
PyExc_LookupError
IndexError
.
_pytype
=
PyExc_IndexError
KeyError
.
_pytype
=
PyExc_KeyError
TypeError
.
_pytype
=
PyExc_TypeError
ArithmeticError
.
_pytype
=
PyExc_ArithmeticError
ZeroDivisionError
.
_pytype
=
PyExc_ZeroDivisionError
OverflowError
.
_pytype
=
PyExc_OverflowError
AttributeError
.
_pytype
=
PyExc_AttributeError
RuntimeError
.
_pytype
=
PyExc_RuntimeError
NotImplementedError
.
_pytype
=
PyExc_NotImplementedError
StopIteration
.
_pytype
=
PyExc_StopIteration
AssertionError
.
_pytype
=
PyExc_AssertionError
EOFError
.
_pytype
=
PyExc_EOFError
SystemExit
.
_pytype
=
PyExc_SystemExit
def
setup_python
(
python_loaded
:
bool
):
global
_PY_INITIALIZED
if
_PY_INITIALIZED
:
return
py_handle
=
cobj
()
if
python_loaded
:
py_handle
=
dlopen
(
""
,
RTLD_LOCAL
|
RTLD_NOW
)
else
:
LD
=
os
.
getenv
(
"CODON_PYTHON"
,
default
=
"libpython."
+
dlext
())
py_handle
=
dlopen
(
LD
,
RTLD_LOCAL
|
RTLD_NOW
)
init_handles_dlopen
(
py_handle
)
init_error_py_types
()
if
not
python_loaded
:
Py_Initialize
()
PyOS_setsig
(
i32
(
2
),
cobj
())
# disable CPython's SIGINT handler
_PY_INITIALIZED
=
True
def
ensure_initialized
(
python_loaded
:
bool
=
False
):
if
__py_extension__
:
init_handles_static
()
init_error_py_types
()
else
:
setup_python
(
python_loaded
)
PyRun_SimpleString
(
_PY_INIT
.
c_str
())
def
setup_decorator
():
setup_python
(
True
)
@
tuple
class
_PyArg_Parser
:
initialized
:
i32
format
:
cobj
keywords
:
Ptr
[
cobj
]
fname
:
cobj
custom_msg
:
cobj
pos
:
i32
min
:
i32
max
:
i32
kwtuple
:
cobj
next
:
cobj
def
__new__
(
fname
:
cobj
,
keywords
:
Ptr
[
cobj
],
format
:
cobj
):
z
=
i32
(
0
)
o
=
cobj
()
return
_PyArg_Parser
(
z
,
format
,
keywords
,
fname
,
o
,
z
,
z
,
z
,
o
,
o
)
@
dataclass
(
init
=
False
)
class
PyError
(
Exception
):
pytype
:
pyobj
def
__init__
(
self
,
message
:
str
):
super
().
__init__
(
message
)
self
.
pytype
=
pyobj
(
cobj
(),
steal
=
True
)
@
overload
def
__init__
(
self
,
message
:
str
,
pytype
:
pyobj
):
super
().
__init__
(
message
)
self
.
pytype
=
pytype
def
_apply1
(
func
,
obj
:
cobj
,
*
args
):
return
pyobj
(
pyobj
.
exc_wrap
(
func
(
obj
,
*
args
)),
steal
=
True
)
def
_apply2
(
func
,
obj
:
cobj
,
other
,
*
args
):
if
isinstance
(
other
,
pyobj
):
return
pyobj
(
pyobj
.
exc_wrap
(
func
(
obj
,
other
.
p
,
*
args
)),
steal
=
True
)
else
:
other_py
=
other
.
__to_py__
()
try
:
return
pyobj
(
pyobj
.
exc_wrap
(
func
(
obj
,
other_py
,
*
args
)),
steal
=
True
)
finally
:
pyobj
.
decref
(
other_py
)
def
_rapply2
(
func
,
obj
:
cobj
,
other
,
*
args
):
if
isinstance
(
other
,
pyobj
):
return
pyobj
(
pyobj
.
exc_wrap
(
func
(
other
.
p
,
obj
,
*
args
)),
steal
=
True
)
else
:
other_py
=
other
.
__to_py__
()
try
:
return
pyobj
(
pyobj
.
exc_wrap
(
func
(
other_py
,
obj
,
*
args
)),
steal
=
True
)
View remainder of file in raw view
Back
|
FazBrowse Home
|
New Git URL