Commit bd00241
authored
[eudsl-python-extras] drop support for generics for py < 3.12 (#236)
After much consternation and flaggelation, I've decided we
can't/shouldn't support generics for python < 3.12. The context/reason
is that I thought I had robust support for just plain `TypeVar`s as
globals (and in the closure) but recently I've realized that that
support is not robust.
In the weeds: the "generic" kernel instantiation effectively mutates the
`TypeVar` and thus when the `TypeVar` is a global, multiple
instantiations of the same kernel (with different concrete params) will
race (on that global `TypeVar`). `TypeVar`s in the closure don't suffer
from this because we copy the `body_builder` and its closure when
instantiating the kernel. In 3.12 (when using the brackets `def fun[M,
N, ...]` syntax) the `TypeVar`s are always in the closure[^1]. I tried
to figure out somehow to move globals into closures but failed and
decided it's not worth the effort anyway.
Note, the added test (`test_generics`) is gated behind 3.13 because
generics default value assignment is a 3.13 feature and the 3.12 parser
will choke on it, but everything else works in 3.12.
[^1]: That's actually a CPython implementation detail - there's a
compiler transform which rewrites the function into a closed over
function with those TypeVars in its closure.1 parent 82e1725 commit bd00241
File tree
8 files changed
+620
-894
lines changed- .github/workflows
- projects/eudsl-python-extras
- mlir/extras
- ast
- dialects
- tests/dialect
8 files changed
+620
-894
lines changedLines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
175 | 176 | | |
176 | 177 | | |
177 | 178 | | |
178 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
179 | 187 | | |
180 | 188 | | |
181 | 189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
Lines changed: 19 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
11 | | - | |
| 10 | + | |
12 | 11 | | |
| 12 | + | |
13 | 13 | | |
14 | | - | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| |||
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
30 | | - | |
31 | 29 | | |
32 | 30 | | |
33 | 31 | | |
| |||
175 | 173 | | |
176 | 174 | | |
177 | 175 | | |
178 | | - | |
| 176 | + | |
179 | 177 | | |
180 | 178 | | |
181 | 179 | | |
| |||
323 | 321 | | |
324 | 322 | | |
325 | 323 | | |
326 | | - | |
| 324 | + | |
327 | 325 | | |
328 | 326 | | |
329 | 327 | | |
330 | 328 | | |
331 | 329 | | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
339 | 334 | | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
347 | 339 | | |
348 | 340 | | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
| 341 | + | |
353 | 342 | | |
354 | 343 | | |
355 | 344 | | |
| |||
372 | 361 | | |
373 | 362 | | |
374 | 363 | | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
| 364 | + | |
379 | 365 | | |
380 | 366 | | |
381 | | - | |
382 | | - | |
383 | | - | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
384 | 371 | | |
385 | 372 | | |
386 | 373 | | |
| |||
419 | 406 | | |
420 | 407 | | |
421 | 408 | | |
422 | | - | |
423 | 409 | | |
424 | 410 | | |
425 | 411 | | |
426 | | - | |
427 | | - | |
428 | 412 | | |
429 | 413 | | |
430 | 414 | | |
| |||
436 | 420 | | |
437 | 421 | | |
438 | 422 | | |
439 | | - | |
| 423 | + | |
440 | 424 | | |
441 | 425 | | |
442 | 426 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| |||
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
| |||
439 | 442 | | |
440 | 443 | | |
441 | 444 | | |
442 | | - | |
443 | 445 | | |
444 | 446 | | |
445 | 447 | | |
446 | 448 | | |
447 | | - | |
448 | | - | |
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
| |||
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
458 | | - | |
| 458 | + | |
459 | 459 | | |
460 | 460 | | |
461 | 461 | | |
| |||
0 commit comments