Cython 3.2.6__py3-none-any.whl → 3.3.0a2.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of Cython might be problematic. Click here for more details.
- Cython/Build/BuildExecutable.py +1 -14
- Cython/Build/Dependencies.py +6 -44
- Cython/Build/Inline.py +7 -3
- Cython/Build/IpythonMagic.py +0 -1
- Cython/Build/SharedModule.py +1 -2
- Cython/Build/Tests/TestCythonizeArgsParser.py +6 -6
- Cython/Build/Tests/TestDependencies.py +3 -3
- Cython/Build/Tests/TestInline.py +3 -3
- Cython/Build/Tests/TestIpythonMagic.py +35 -19
- Cython/Build/Tests/TestStripLiterals.py +2 -2
- Cython/Compiler/Buffer.py +5 -5
- Cython/Compiler/Builtin.py +57 -46
- Cython/Compiler/Code.pxd +12 -9
- Cython/Compiler/Code.py +220 -94
- Cython/Compiler/Dataclass.py +78 -52
- Cython/Compiler/Errors.py +21 -8
- Cython/Compiler/ExprNodes.py +871 -459
- Cython/Compiler/FlowControl.pxd +8 -6
- Cython/Compiler/FlowControl.py +111 -8
- Cython/Compiler/FusedNode.py +17 -12
- Cython/Compiler/Lexicon.py +123 -122
- Cython/Compiler/Main.py +3 -4
- Cython/Compiler/MatchCaseNodes.py +1948 -10
- Cython/Compiler/MemoryView.py +62 -33
- Cython/Compiler/ModuleNode.py +559 -283
- Cython/Compiler/Naming.py +4 -0
- Cython/Compiler/Nodes.py +333 -197
- Cython/Compiler/Optimize.py +268 -112
- Cython/Compiler/Options.py +0 -5
- Cython/Compiler/ParseTreeTransforms.pxd +2 -1
- Cython/Compiler/ParseTreeTransforms.py +180 -76
- Cython/Compiler/Parsing.py +55 -38
- Cython/Compiler/PyrexTypes.py +364 -128
- Cython/Compiler/Scanning.pxd +27 -5
- Cython/Compiler/Scanning.py +24 -14
- Cython/Compiler/StringEncoding.py +1 -2
- Cython/Compiler/Symtab.py +27 -19
- Cython/Compiler/Tests/TestBuiltin.py +41 -6
- Cython/Compiler/Tests/TestCmdLine.py +3 -2
- Cython/Compiler/Tests/TestCode.py +4 -3
- Cython/Compiler/Tests/TestFlowControl.py +2 -2
- Cython/Compiler/Tests/TestParseTreeTransforms.py +2 -2
- Cython/Compiler/Tests/TestScanning.py +2 -4
- Cython/Compiler/Tests/TestSignatureMatching.py +3 -3
- Cython/Compiler/Tests/TestStringEncoding.py +2 -3
- Cython/Compiler/Tests/TestTypes.py +46 -3
- Cython/Compiler/Tests/TestUtilityLoad.py +4 -4
- Cython/Compiler/TypeInference.py +20 -0
- Cython/Compiler/TypeSlots.py +171 -16
- Cython/Compiler/UtilNodes.py +24 -0
- Cython/Compiler/UtilityCode.py +1 -0
- Cython/Compiler/Visitor.pxd +1 -1
- Cython/Compiler/Visitor.py +3 -2
- Cython/Debugger/Tests/TestLibCython.py +7 -2
- Cython/Debugger/Tests/test_libcython_in_gdb.py +4 -2
- Cython/Debugger/Tests/test_libpython_in_gdb.py +1 -1
- Cython/Includes/cpython/array.pxd +5 -5
- Cython/Includes/cpython/dict.pxd +1 -6
- Cython/Includes/cpython/float.pxd +19 -10
- Cython/Includes/cpython/frozendict.pxd +37 -0
- Cython/Includes/cpython/long.pxd +31 -0
- Cython/Includes/cpython/object.pxd +9 -12
- Cython/Includes/cpython/sentinel.pxd +17 -0
- Cython/Includes/cpython/type.pxd +93 -0
- Cython/Includes/libcpp/exception.pxd +90 -0
- Cython/LZSS.py +170 -0
- Cython/Shadow.py +550 -73
- Cython/StringIOTree.py +1 -2
- Cython/Tempita/_tempita.py +45 -46
- Cython/TestUtils.py +50 -8
- Cython/Tests/TestCythonUtils.py +2 -2
- Cython/Tests/TestJediTyper.py +1 -1
- Cython/Tests/TestShadow.py +7 -5
- Cython/Tests/TestStringIOTree.py +4 -3
- Cython/Tests/TestTestUtils.py +2 -3
- Cython/Utility/AsyncGen.c +59 -19
- Cython/Utility/Buffer.c +4 -3
- Cython/Utility/Builtins.c +139 -17
- Cython/Utility/CConvert.pyx +27 -12
- Cython/Utility/CommonStructures.c +55 -37
- Cython/Utility/Coroutine.c +112 -68
- Cython/Utility/CythonFunction.c +607 -330
- Cython/Utility/Embed.c +8 -0
- Cython/Utility/Exceptions.c +20 -3
- Cython/Utility/ExtensionTypes.c +414 -224
- Cython/Utility/FunctionArguments.c +83 -81
- Cython/Utility/ImportExport.c +72 -61
- Cython/Utility/MatchCase.c +979 -0
- Cython/Utility/MatchCase_Cy.pyx +12 -0
- Cython/Utility/MemoryView.pxd +9 -88
- Cython/Utility/MemoryView.pyx +173 -61
- Cython/Utility/MemoryView_C.c +3 -3
- Cython/Utility/ModuleSetupCode.c +306 -157
- Cython/Utility/ObjectHandling.c +483 -404
- Cython/Utility/Optimize.c +1117 -164
- Cython/Utility/Overflow.c +3 -9
- Cython/Utility/Profile.c +4 -0
- Cython/Utility/StringTools.c +187 -149
- Cython/Utility/Synchronization.c +39 -0
- Cython/Utility/TString.c +24 -13
- Cython/Utility/TypeConversion.c +405 -250
- Cython/Utility/arrayarray.h +24 -22
- Cython/Utils.py +11 -23
- Cython/__init__.py +3 -1
- {cython-3.2.6.dist-info → cython-3.3.0a2.dev0.dist-info}/METADATA +14 -33
- {cython-3.2.6.dist-info → cython-3.3.0a2.dev0.dist-info}/RECORD +109 -107
- {cython-3.2.6.dist-info → cython-3.3.0a2.dev0.dist-info}/WHEEL +1 -1
- Cython/Shadow.pyi +0 -521
- Cython/Utility/Printing.c +0 -86
- Cython/__init__.pyi +0 -7
- {cython-3.2.6.dist-info → cython-3.3.0a2.dev0.dist-info}/entry_points.txt +0 -0
- {cython-3.2.6.dist-info → cython-3.3.0a2.dev0.dist-info}/top_level.txt +0 -0
Cython/Compiler/MemoryView.py
CHANGED
|
@@ -69,6 +69,8 @@ def put_acquire_memoryviewslice(lhs_cname, lhs_type, lhs_pos, rhs, code,
|
|
|
69
69
|
"We can avoid decreffing the lhs if we know it is the first assignment"
|
|
70
70
|
assert rhs.type.is_memoryviewslice
|
|
71
71
|
|
|
72
|
+
rhs_is_borrowed_temp = rhs.is_memview_slice and rhs.use_borrowed_ref
|
|
73
|
+
|
|
72
74
|
pretty_rhs = rhs.result_in_temp() or rhs.is_simple()
|
|
73
75
|
if pretty_rhs:
|
|
74
76
|
rhstmp = rhs.result()
|
|
@@ -79,23 +81,33 @@ def put_acquire_memoryviewslice(lhs_cname, lhs_type, lhs_pos, rhs, code,
|
|
|
79
81
|
# Allow uninitialized assignment
|
|
80
82
|
#code.putln(code.put_error_if_unbound(lhs_pos, rhs.entry))
|
|
81
83
|
put_assign_to_memviewslice(lhs_cname, rhs, rhstmp, lhs_type, code,
|
|
82
|
-
have_gil=have_gil, first_assignment=first_assignment
|
|
84
|
+
have_gil=have_gil, first_assignment=first_assignment,
|
|
85
|
+
rhs_is_borrowed_temp=rhs_is_borrowed_temp)
|
|
83
86
|
|
|
84
87
|
if not pretty_rhs:
|
|
85
88
|
code.funcstate.release_temp(rhstmp)
|
|
86
89
|
|
|
87
90
|
|
|
88
91
|
def put_assign_to_memviewslice(lhs_cname, rhs, rhs_cname, memviewslicetype, code,
|
|
89
|
-
have_gil=False, first_assignment=False
|
|
92
|
+
have_gil=False, first_assignment=False,
|
|
93
|
+
rhs_is_borrowed_temp=False):
|
|
90
94
|
if lhs_cname == rhs_cname:
|
|
91
95
|
# self assignment is tricky because memoryview xdecref clears the memoryview
|
|
92
96
|
# thus invalidating both sides of the assignment. Therefore make it actually do nothing
|
|
93
97
|
code.putln("/* memoryview self assignment no-op */")
|
|
94
98
|
return
|
|
95
99
|
|
|
100
|
+
if rhs_is_borrowed_temp and not first_assignment:
|
|
101
|
+
# Here we can skip the reference counting in the fairly likely case
|
|
102
|
+
# that the lhs and rhs are equal (e.g. repeated slicing in a loop).
|
|
103
|
+
code.putln(f"if ({lhs_cname}.memview != {rhs_cname}.memview) ""{")
|
|
96
104
|
if not first_assignment:
|
|
97
105
|
code.put_xdecref(lhs_cname, memviewslicetype,
|
|
98
106
|
have_gil=have_gil)
|
|
107
|
+
if rhs_is_borrowed_temp:
|
|
108
|
+
code.put_incref_memoryviewslice(rhs_cname, memviewslicetype, have_gil=have_gil)
|
|
109
|
+
if not first_assignment:
|
|
110
|
+
code.putln("}")
|
|
99
111
|
|
|
100
112
|
if not rhs.result_in_temp():
|
|
101
113
|
rhs.make_owned_memoryviewslice(code)
|
|
@@ -243,7 +255,7 @@ class MemoryViewSliceBufferEntry(Buffer.BufferEntry):
|
|
|
243
255
|
return bufp
|
|
244
256
|
|
|
245
257
|
def generate_buffer_slice_code(self, code, indices, dst, dst_type, have_gil,
|
|
246
|
-
have_slices, directives):
|
|
258
|
+
have_slices, directives, drop_temp_refcounting):
|
|
247
259
|
"""
|
|
248
260
|
Slice a memoryviewslice.
|
|
249
261
|
|
|
@@ -257,9 +269,10 @@ class MemoryViewSliceBufferEntry(Buffer.BufferEntry):
|
|
|
257
269
|
"""
|
|
258
270
|
src = self.cname
|
|
259
271
|
|
|
260
|
-
code.putln("
|
|
261
|
-
code.putln("
|
|
262
|
-
|
|
272
|
+
code.putln(f"{dst}.data = {src}.data;")
|
|
273
|
+
code.putln(f"{dst}.memview = {src}.memview;")
|
|
274
|
+
if not drop_temp_refcounting:
|
|
275
|
+
code.put_incref_memoryviewslice(dst, dst_type, have_gil=have_gil)
|
|
263
276
|
|
|
264
277
|
all_dimensions_direct = all(access == 'direct' for access, packing in self.type.axes)
|
|
265
278
|
suboffset_dim_temp = []
|
|
@@ -268,17 +281,28 @@ class MemoryViewSliceBufferEntry(Buffer.BufferEntry):
|
|
|
268
281
|
# create global temp variable at request
|
|
269
282
|
if not suboffset_dim_temp:
|
|
270
283
|
suboffset_dim = code.funcstate.allocate_temp(PyrexTypes.c_int_type, manage_ref=False)
|
|
271
|
-
code.putln("
|
|
284
|
+
code.putln(f"{suboffset_dim} = -1;")
|
|
272
285
|
suboffset_dim_temp.append(suboffset_dim)
|
|
273
286
|
return suboffset_dim_temp[0]
|
|
274
287
|
|
|
288
|
+
boundscheck = directives['boundscheck']
|
|
289
|
+
template_vars = {
|
|
290
|
+
'src': src,
|
|
291
|
+
'dst': dst,
|
|
292
|
+
'have_gil': have_gil,
|
|
293
|
+
'get_suboffset_dim': get_suboffset_dim,
|
|
294
|
+
'all_dimensions_direct': all_dimensions_direct,
|
|
295
|
+
'wraparound': int(directives['wraparound']),
|
|
296
|
+
'boundscheck': int(boundscheck),
|
|
297
|
+
}
|
|
298
|
+
|
|
275
299
|
dim = -1
|
|
276
300
|
new_ndim = 0
|
|
277
301
|
for index in indices:
|
|
278
302
|
if index.is_none:
|
|
279
303
|
# newaxis
|
|
280
304
|
for attrib, value in [('shape', 1), ('strides', 0), ('suboffsets', -1)]:
|
|
281
|
-
code.putln("
|
|
305
|
+
code.putln(f"{dst}.{attrib}[{new_ndim:d}] = {value:d};")
|
|
282
306
|
|
|
283
307
|
new_ndim += 1
|
|
284
308
|
continue
|
|
@@ -286,18 +310,29 @@ class MemoryViewSliceBufferEntry(Buffer.BufferEntry):
|
|
|
286
310
|
dim += 1
|
|
287
311
|
access, packing = self.type.axes[dim]
|
|
288
312
|
|
|
313
|
+
d = dict(
|
|
314
|
+
template_vars,
|
|
315
|
+
dim=dim,
|
|
316
|
+
new_ndim=new_ndim,
|
|
317
|
+
access=access,
|
|
318
|
+
)
|
|
319
|
+
|
|
289
320
|
if index.is_slice:
|
|
290
321
|
# slice, unspecified dimension, or part of ellipsis
|
|
291
|
-
|
|
292
|
-
for s in "start stop step"
|
|
322
|
+
is_full_slice = True
|
|
323
|
+
for s in ("start", "stop", "step"):
|
|
293
324
|
idx = getattr(index, s)
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
325
|
+
if idx.is_none:
|
|
326
|
+
d['have_' + s] = False
|
|
327
|
+
d[s] = "0"
|
|
328
|
+
else:
|
|
329
|
+
is_full_slice = False
|
|
330
|
+
d['have_' + s] = True
|
|
331
|
+
d[s] = idx.result()
|
|
332
|
+
|
|
333
|
+
if is_full_slice:
|
|
334
|
+
# For a full slice (:), we just copy over the extent, stride and suboffset.
|
|
335
|
+
# Also update suboffset_dim if needed.
|
|
301
336
|
util_name = "SimpleSlice"
|
|
302
337
|
else:
|
|
303
338
|
util_name = "ToughSlice"
|
|
@@ -307,24 +342,18 @@ class MemoryViewSliceBufferEntry(Buffer.BufferEntry):
|
|
|
307
342
|
new_ndim += 1
|
|
308
343
|
else:
|
|
309
344
|
# normal index
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
d = dict(
|
|
321
|
-
locals(),
|
|
322
|
-
wraparound=int(directives['wraparound']),
|
|
323
|
-
boundscheck=int(directives['boundscheck']),
|
|
345
|
+
if access != 'direct' and new_ndim != 0:
|
|
346
|
+
error(index.pos, "All preceding dimensions must be indexed and not sliced")
|
|
347
|
+
return
|
|
348
|
+
|
|
349
|
+
util_name = "SliceIndex"
|
|
350
|
+
d.update(
|
|
351
|
+
idx=index.result(),
|
|
352
|
+
indirect=access != 'direct',
|
|
353
|
+
generic=access == 'full',
|
|
324
354
|
)
|
|
325
|
-
if
|
|
355
|
+
if boundscheck:
|
|
326
356
|
d['error_goto'] = code.error_goto(index.pos)
|
|
327
|
-
util_name = "SliceIndex"
|
|
328
357
|
|
|
329
358
|
_, impl = TempitaUtilityCode.load_as_string(util_name, "MemoryView_C.c", context=d)
|
|
330
359
|
code.put(impl)
|