75
75
76
76
Equivalent to `setattr(x, k, v)` or `x.k = v` in Python.
77
77
"""
78
- pysetattr (x, k, v) = (
79
- errcheck (@autopy x k v C. PyObject_SetAttr (x_, k_, v_)); nothing
80
- )
78
+ pysetattr (x, k, v) = (errcheck (@autopy x k v C. PyObject_SetAttr (x_, k_, v_)); nothing )
81
79
82
80
"""
83
81
pydelattr(x, k)
84
82
85
83
Equivalent to `delattr(x, k)` or `del x.k` in Python.
86
84
"""
87
- pydelattr (x, k) =
88
- (errcheck (@autopy x k C. PyObject_SetAttr (x_, k_, C. PyNULL)); nothing )
85
+ pydelattr (x, k) = (errcheck (@autopy x k C. PyObject_SetAttr (x_, k_, C. PyNULL)); nothing )
89
86
90
87
"""
91
88
pyissubclass(s, t)
92
89
93
90
Test if `s` is a subclass of `t`. Equivalent to `issubclass(s, t)` in Python.
94
91
"""
95
- pyissubclass (s, t) =
96
- errcheck (@autopy s t C. PyObject_IsSubclass (s_, t_)) == 1
92
+ pyissubclass (s, t) = errcheck (@autopy s t C. PyObject_IsSubclass (s_, t_)) == 1
97
93
98
94
"""
99
95
pyisinstance(x, t)
100
96
101
97
Test if `x` is of type `t`. Equivalent to `isinstance(x, t)` in Python.
102
98
"""
103
- pyisinstance (x, t) =
104
- errcheck (@autopy x t C. PyObject_IsInstance (x_, t_)) == 1
99
+ pyisinstance (x, t) = errcheck (@autopy x t C. PyObject_IsInstance (x_, t_)) == 1
105
100
106
101
"""
107
102
pyhash(x)
@@ -179,17 +174,14 @@ end
179
174
180
175
Equivalent to `setitem(x, k, v)` or `x[k] = v` in Python.
181
176
"""
182
- pysetitem (x, k, v) = (
183
- errcheck (@autopy x k v C. PyObject_SetItem (x_, k_, v_)); nothing
184
- )
177
+ pysetitem (x, k, v) = (errcheck (@autopy x k v C. PyObject_SetItem (x_, k_, v_)); nothing )
185
178
186
179
"""
187
180
pydelitem(x, k)
188
181
189
182
Equivalent to `delitem(x, k)` or `del x[k]` in Python.
190
183
"""
191
- pydelitem (x, k) =
192
- (errcheck (@autopy x k C. PyObject_DelItem (x_, k_)); nothing )
184
+ pydelitem (x, k) = (errcheck (@autopy x k C. PyObject_DelItem (x_, k_)); nothing )
193
185
194
186
"""
195
187
pydir(x)
@@ -199,13 +191,9 @@ Equivalent to `dir(x)` in Python.
199
191
pydir (x) = pynew (errcheck (@autopy x C. PyObject_Dir (x_)))
200
192
201
193
pycallargs (f) = pynew (errcheck (@autopy f C. PyObject_CallObject (f_, C. PyNULL)))
202
- pycallargs (f, args) =
203
- pynew (errcheck (@autopy f args C. PyObject_CallObject (f_, args_)))
204
- pycallargs (f, args, kwargs) = pynew (
205
- errcheck (
206
- @autopy f args kwargs C. PyObject_Call (f_, args_, kwargs_)
207
- ),
208
- )
194
+ pycallargs (f, args) = pynew (errcheck (@autopy f args C. PyObject_CallObject (f_, args_)))
195
+ pycallargs (f, args, kwargs) =
196
+ pynew (errcheck (@autopy f args kwargs C. PyObject_Call (f_, args_, kwargs_)))
209
197
210
198
"""
211
199
pycall(f, args...; kwargs...)
@@ -235,53 +223,47 @@ pycall(f, args...; kwargs...) =
235
223
236
224
Equivalent to `x == y` in Python. The second form converts to `Bool`.
237
225
"""
238
- pyeq (x, y) =
239
- pynew (errcheck (@autopy x y C. PyObject_RichCompare (x_, y_, C. Py_EQ)))
226
+ pyeq (x, y) = pynew (errcheck (@autopy x y C. PyObject_RichCompare (x_, y_, C. Py_EQ)))
240
227
241
228
"""
242
229
pyne(x, y)
243
230
pyne(Bool, x, y)
244
231
245
232
Equivalent to `x != y` in Python. The second form converts to `Bool`.
246
233
"""
247
- pyne (x, y) =
248
- pynew (errcheck (@autopy x y C. PyObject_RichCompare (x_, y_, C. Py_NE)))
234
+ pyne (x, y) = pynew (errcheck (@autopy x y C. PyObject_RichCompare (x_, y_, C. Py_NE)))
249
235
250
236
"""
251
237
pyle(x, y)
252
238
pyle(Bool, x, y)
253
239
254
240
Equivalent to `x <= y` in Python. The second form converts to `Bool`.
255
241
"""
256
- pyle (x, y) =
257
- pynew (errcheck (@autopy x y C. PyObject_RichCompare (x_, y_, C. Py_LE)))
242
+ pyle (x, y) = pynew (errcheck (@autopy x y C. PyObject_RichCompare (x_, y_, C. Py_LE)))
258
243
259
244
"""
260
245
pylt(x, y)
261
246
pylt(Bool, x, y)
262
247
263
248
Equivalent to `x < y` in Python. The second form converts to `Bool`.
264
249
"""
265
- pylt (x, y) =
266
- pynew (errcheck (@autopy x y C. PyObject_RichCompare (x_, y_, C. Py_LT)))
250
+ pylt (x, y) = pynew (errcheck (@autopy x y C. PyObject_RichCompare (x_, y_, C. Py_LT)))
267
251
268
252
"""
269
253
pyge(x, y)
270
254
pyge(Bool, x, y)
271
255
272
256
Equivalent to `x >= y` in Python. The second form converts to `Bool`.
273
257
"""
274
- pyge (x, y) =
275
- pynew (errcheck (@autopy x y C. PyObject_RichCompare (x_, y_, C. Py_GE)))
258
+ pyge (x, y) = pynew (errcheck (@autopy x y C. PyObject_RichCompare (x_, y_, C. Py_GE)))
276
259
277
260
"""
278
261
pygt(x, y)
279
262
pygt(Bool, x, y)
280
263
281
264
Equivalent to `x > y` in Python. The second form converts to `Bool`.
282
265
"""
283
- pygt (x, y) =
284
- pynew (errcheck (@autopy x y C. PyObject_RichCompare (x_, y_, C. Py_GT)))
266
+ pygt (x, y) = pynew (errcheck (@autopy x y C. PyObject_RichCompare (x_, y_, C. Py_GT)))
285
267
pyeq (:: Type{Bool} , x, y) =
286
268
errcheck (@autopy x y C. PyObject_RichCompareBool (x_, y_, C. Py_EQ)) == 1
287
269
pyne (:: Type{Bool} , x, y) =
@@ -369,15 +351,13 @@ pymul(x, y) = pynew(errcheck(@autopy x y C.PyNumber_Multiply(x_, y_)))
369
351
370
352
Equivalent to `x @ y` in Python.
371
353
"""
372
- pymatmul (x, y) =
373
- pynew (errcheck (@autopy x y C. PyNumber_MatrixMultiply (x_, y_)))
354
+ pymatmul (x, y) = pynew (errcheck (@autopy x y C. PyNumber_MatrixMultiply (x_, y_)))
374
355
"""
375
356
pyfloordiv(x, y)
376
357
377
358
Equivalent to `x // y` in Python.
378
359
"""
379
- pyfloordiv (x, y) =
380
- pynew (errcheck (@autopy x y C. PyNumber_FloorDivide (x_, y_)))
360
+ pyfloordiv (x, y) = pynew (errcheck (@autopy x y C. PyNumber_FloorDivide (x_, y_)))
381
361
"""
382
362
pytruediv(x, y)
383
363
@@ -439,57 +419,49 @@ pyiadd(x, y) = pynew(errcheck(@autopy x y C.PyNumber_InPlaceAdd(x_, y_)))
439
419
440
420
In-place subtract. `x = pyisub(x, y)` is equivalent to `x -= y` in Python.
441
421
"""
442
- pyisub (x, y) =
443
- pynew (errcheck (@autopy x y C. PyNumber_InPlaceSubtract (x_, y_)))
422
+ pyisub (x, y) = pynew (errcheck (@autopy x y C. PyNumber_InPlaceSubtract (x_, y_)))
444
423
"""
445
424
pyimul(x, y)
446
425
447
426
In-place multiply. `x = pyimul(x, y)` is equivalent to `x *= y` in Python.
448
427
"""
449
- pyimul (x, y) =
450
- pynew (errcheck (@autopy x y C. PyNumber_InPlaceMultiply (x_, y_)))
428
+ pyimul (x, y) = pynew (errcheck (@autopy x y C. PyNumber_InPlaceMultiply (x_, y_)))
451
429
"""
452
430
pyimatmul(x, y)
453
431
454
432
In-place matrix multiply. `x = pyimatmul(x, y)` is equivalent to `x @= y` in Python.
455
433
"""
456
- pyimatmul (x, y) =
457
- pynew (errcheck (@autopy x y C. PyNumber_InPlaceMatrixMultiply (x_, y_)))
434
+ pyimatmul (x, y) = pynew (errcheck (@autopy x y C. PyNumber_InPlaceMatrixMultiply (x_, y_)))
458
435
"""
459
436
pyifloordiv(x, y)
460
437
461
438
In-place floor divide. `x = pyifloordiv(x, y)` is equivalent to `x //= y` in Python.
462
439
"""
463
- pyifloordiv (x, y) =
464
- pynew (errcheck (@autopy x y C. PyNumber_InPlaceFloorDivide (x_, y_)))
440
+ pyifloordiv (x, y) = pynew (errcheck (@autopy x y C. PyNumber_InPlaceFloorDivide (x_, y_)))
465
441
"""
466
442
pyitruediv(x, y)
467
443
468
444
In-place true division. `x = pyitruediv(x, y)` is equivalent to `x /= y` in Python.
469
445
"""
470
- pyitruediv (x, y) =
471
- pynew (errcheck (@autopy x y C. PyNumber_InPlaceTrueDivide (x_, y_)))
446
+ pyitruediv (x, y) = pynew (errcheck (@autopy x y C. PyNumber_InPlaceTrueDivide (x_, y_)))
472
447
"""
473
448
pyimod(x, y)
474
449
475
450
In-place subtraction. `x = pyimod(x, y)` is equivalent to `x %= y` in Python.
476
451
"""
477
- pyimod (x, y) =
478
- pynew (errcheck (@autopy x y C. PyNumber_InPlaceRemainder (x_, y_)))
452
+ pyimod (x, y) = pynew (errcheck (@autopy x y C. PyNumber_InPlaceRemainder (x_, y_)))
479
453
"""
480
454
pyilshift(x, y)
481
455
482
456
In-place left shift. `x = pyilshift(x, y)` is equivalent to `x <<= y` in Python.
483
457
"""
484
- pyilshift (x, y) =
485
- pynew (errcheck (@autopy x y C. PyNumber_InPlaceLshift (x_, y_)))
458
+ pyilshift (x, y) = pynew (errcheck (@autopy x y C. PyNumber_InPlaceLshift (x_, y_)))
486
459
"""
487
460
pyirshift(x, y)
488
461
489
462
In-place right shift. `x = pyirshift(x, y)` is equivalent to `x >>= y` in Python.
490
463
"""
491
- pyirshift (x, y) =
492
- pynew (errcheck (@autopy x y C. PyNumber_InPlaceRshift (x_, y_)))
464
+ pyirshift (x, y) = pynew (errcheck (@autopy x y C. PyNumber_InPlaceRshift (x_, y_)))
493
465
"""
494
466
pyiand(x, y)
495
467
@@ -522,9 +494,8 @@ pypow(x, y, z = pybuiltins.None) =
522
494
523
495
In-place power. `x = pyipow(x, y)` is equivalent to `x **= y` in Python.
524
496
"""
525
- pyipow (x, y, z = pybuiltins. None) = pynew (
526
- errcheck (@autopy x y z C. PyNumber_InPlacePower (x_, y_, z_)),
527
- )
497
+ pyipow (x, y, z = pybuiltins. None) =
498
+ pynew (errcheck (@autopy x y z C. PyNumber_InPlacePower (x_, y_, z_)))
528
499
529
500
# ## iter
530
501
@@ -1001,8 +972,7 @@ pyfrozenset(x) = ispy(x) ? pybuiltins.frozenset(x) : pyfrozenset_fromiter(x)
1001
972
1002
973
# ## dict
1003
974
1004
- pydict_setitem (x:: Py , k, v) =
1005
- errcheck (@autopy k v C. PyDict_SetItem (x, k_, v_))
975
+ pydict_setitem (x:: Py , k, v) = errcheck (@autopy k v C. PyDict_SetItem (x, k_, v_))
1006
976
1007
977
function pydict_fromiter (kvs)
1008
978
ans = pydict ()
1023
993
"""
1024
994
pydict(x)
1025
995
pydict(; x...)
996
+ pydict(x::Pair...)
1026
997
1027
998
Convert `x` to a Python `dict`. In the second form, the keys are strings.
1028
999
@@ -1033,6 +1004,7 @@ pydict(; kwargs...) =
1033
1004
isempty (kwargs) ? pynew (errcheck (C. PyDict_New ())) : pystrdict_fromiter (kwargs)
1034
1005
pydict (x) = ispy (x) ? pybuiltins. dict (x) : pydict_fromiter (x)
1035
1006
pydict (x:: NamedTuple ) = pydict (; x... )
1007
+ pydict (pair:: Pair , pairs:: Pair... ) = pydict ((pair, pairs... ))
1036
1008
1037
1009
# ## datetime
1038
1010
0 commit comments