From 697e4eac1d1aa7e6d5fa567b079a8073efca81c6 Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Thu, 7 May 2026 11:24:16 +0100 Subject: [PATCH] [mypyc] Mark librt.vecs as non-experimental Compile contents without an opt-in flag. --- mypyc/lib-rt/vecs/librt_vecs.c | 8 -------- mypyc/lib-rt/vecs/librt_vecs.h | 4 ---- mypyc/lib-rt/vecs/librt_vecs_api.c | 13 ------------- mypyc/lib-rt/vecs/librt_vecs_api.h | 4 ---- mypyc/lib-rt/vecs/vec_bool.c | 3 --- mypyc/lib-rt/vecs/vec_float.c | 3 --- mypyc/lib-rt/vecs/vec_i16.c | 3 --- mypyc/lib-rt/vecs/vec_i32.c | 3 --- mypyc/lib-rt/vecs/vec_i64.c | 3 --- mypyc/lib-rt/vecs/vec_nested.c | 3 --- mypyc/lib-rt/vecs/vec_t.c | 3 --- mypyc/lib-rt/vecs/vec_template.c | 3 --- mypyc/lib-rt/vecs/vec_u8.c | 3 --- mypyc/lib-rt/vecs_extra_ops.c | 4 ---- mypyc/lib-rt/vecs_extra_ops.h | 4 ---- mypyc/primitives/librt_vecs_ops.py | 2 -- mypyc/test-data/capsule-deps.test | 8 ++++---- mypyc/test-data/irbuild-vec-misc.test | 2 +- mypyc/test-data/run-vecs-i64-interp.test | 2 +- mypyc/test-data/run-vecs-i64.test | 2 +- mypyc/test-data/run-vecs-misc-interp.test | 15 ++------------- mypyc/test-data/run-vecs-misc.test | 2 +- mypyc/test-data/run-vecs-nested-interp.test | 2 +- mypyc/test-data/run-vecs-nested.test | 2 +- mypyc/test-data/run-vecs-t-interp.test | 2 +- mypyc/test-data/run-vecs-t.test | 2 +- 26 files changed, 14 insertions(+), 91 deletions(-) diff --git a/mypyc/lib-rt/vecs/librt_vecs.c b/mypyc/lib-rt/vecs/librt_vecs.c index 023f1552588da..67c2148005b25 100644 --- a/mypyc/lib-rt/vecs/librt_vecs.c +++ b/mypyc/lib-rt/vecs/librt_vecs.c @@ -74,8 +74,6 @@ #include #include "librt_vecs.h" -#ifdef MYPYC_EXPERIMENTAL - PyTypeObject *LibRTVecs_I64TypeObj; PyTypeObject *LibRTVecs_I32TypeObj; PyTypeObject *LibRTVecs_I16TypeObj; @@ -982,22 +980,17 @@ static VecCapsule Capsule = { get_vec_type, }; -#endif // MYPYC_EXPERIMENTAL - static PyMethodDef VecsMethods[] = { -#ifdef MYPYC_EXPERIMENTAL {"append", vec_append, METH_VARARGS, "Append a value to the end of a vec"}, {"remove", vec_remove, METH_VARARGS, "Remove first occurrence of value from a vec"}, {"pop", vec_pop, METH_VARARGS, "Remove and return vec item at index (default last)"}, {"extend", vec_extend, METH_VARARGS, "Extend a vec with items from an iterable"}, -#endif {NULL, NULL, 0, NULL} /* Sentinel */ }; static int librt_vecs_module_exec(PyObject *m) { -#ifdef MYPYC_EXPERIMENTAL PyObject *ext = PyImport_ImportModule("mypy_extensions"); if (ext == NULL) { return -1; @@ -1109,7 +1102,6 @@ librt_vecs_module_exec(PyObject *m) } Py_DECREF(ext); -#endif return 0; } diff --git a/mypyc/lib-rt/vecs/librt_vecs.h b/mypyc/lib-rt/vecs/librt_vecs.h index b7700d4bd9f77..73a16225aee26 100644 --- a/mypyc/lib-rt/vecs/librt_vecs.h +++ b/mypyc/lib-rt/vecs/librt_vecs.h @@ -20,8 +20,6 @@ // ABI version is changed, but see the comment above). #define LIBRT_VECS_API_VERSION 1 -#ifdef MYPYC_EXPERIMENTAL - // Magic (native) integer return value on exception. Caller must also // use PyErr_Occurred() since this overlaps with valid integer values. #define MYPYC_INT_ERROR -113 @@ -997,6 +995,4 @@ int Vec_GenericRemove(Py_ssize_t *len, PyObject **items, PyObject *item); PyObject *Vec_GenericPopWrapper(Py_ssize_t *len, PyObject **items, PyObject *args); PyObject *Vec_GenericPop(Py_ssize_t *len, PyObject **items, Py_ssize_t index); -#endif // MYPYC_EXPERIMENTAL - #endif // VEC_H_INCL diff --git a/mypyc/lib-rt/vecs/librt_vecs_api.c b/mypyc/lib-rt/vecs/librt_vecs_api.c index 9993848f3a2e1..8c45874f1bfd2 100644 --- a/mypyc/lib-rt/vecs/librt_vecs_api.c +++ b/mypyc/lib-rt/vecs/librt_vecs_api.c @@ -1,16 +1,5 @@ #include "librt_vecs_api.h" -#ifndef MYPYC_EXPERIMENTAL - -int -import_librt_vecs(void) -{ - // All librt.vecs features are experimental for now, so don't set up the API here - return 0; -} - -#else - VecCapsule *VecApi = NULL; VecI64API VecI64Api = {0}; VecI32API VecI32Api = {0}; @@ -60,5 +49,3 @@ import_librt_vecs(void) VecNestedApi = *VecApi->nested; return 0; } - -#endif // MYPYC_EXPERIMENTAL diff --git a/mypyc/lib-rt/vecs/librt_vecs_api.h b/mypyc/lib-rt/vecs/librt_vecs_api.h index d7f1cacfea9ea..6f42c0b7251d0 100644 --- a/mypyc/lib-rt/vecs/librt_vecs_api.h +++ b/mypyc/lib-rt/vecs/librt_vecs_api.h @@ -10,8 +10,6 @@ int import_librt_vecs(void); -#ifdef MYPYC_EXPERIMENTAL - // Global API pointers initialized by import_librt_vecs() extern VecCapsule *VecApi; extern VecI64API VecI64Api; @@ -23,6 +21,4 @@ extern VecBoolAPI VecBoolApi; extern VecTAPI VecTApi; extern VecNestedAPI VecNestedApi; -#endif // MYPYC_EXPERIMENTAL - #endif // LIBRT_VECS_API_H diff --git a/mypyc/lib-rt/vecs/vec_bool.c b/mypyc/lib-rt/vecs/vec_bool.c index 54b7a1f783077..e21b66c9dec50 100644 --- a/mypyc/lib-rt/vecs/vec_bool.c +++ b/mypyc/lib-rt/vecs/vec_bool.c @@ -1,4 +1,3 @@ -#ifdef MYPYC_EXPERIMENTAL #define VEC VecBool #define VEC_TYPE VecBoolType #define VEC_OBJECT VecBoolObject @@ -17,5 +16,3 @@ #define BUFFER_FORMAT "b" #include "vec_template.c" - -#endif // MYPYC_EXPERIMENTAL diff --git a/mypyc/lib-rt/vecs/vec_float.c b/mypyc/lib-rt/vecs/vec_float.c index 16822fa5a0e11..9b1f139732b47 100644 --- a/mypyc/lib-rt/vecs/vec_float.c +++ b/mypyc/lib-rt/vecs/vec_float.c @@ -1,4 +1,3 @@ -#ifdef MYPYC_EXPERIMENTAL #define VEC VecFloat #define VEC_TYPE VecFloatType #define VEC_OBJECT VecFloatObject @@ -18,5 +17,3 @@ #define BUFFER_FORMAT "d" #include "vec_template.c" - -#endif // MYPYC_EXPERIMENTAL diff --git a/mypyc/lib-rt/vecs/vec_i16.c b/mypyc/lib-rt/vecs/vec_i16.c index dc1e6dcdec4f6..994b67e7793bf 100644 --- a/mypyc/lib-rt/vecs/vec_i16.c +++ b/mypyc/lib-rt/vecs/vec_i16.c @@ -1,4 +1,3 @@ -#ifdef MYPYC_EXPERIMENTAL #define VEC VecI16 #define VEC_TYPE VecI16Type #define VEC_OBJECT VecI16Object @@ -18,5 +17,3 @@ #define BUFFER_FORMAT "h" #include "vec_template.c" - -#endif // MYPYC_EXPERIMENTAL diff --git a/mypyc/lib-rt/vecs/vec_i32.c b/mypyc/lib-rt/vecs/vec_i32.c index f1a7622506cab..b475815ce4d8d 100644 --- a/mypyc/lib-rt/vecs/vec_i32.c +++ b/mypyc/lib-rt/vecs/vec_i32.c @@ -1,4 +1,3 @@ -#ifdef MYPYC_EXPERIMENTAL #define VEC VecI32 #define VEC_TYPE VecI32Type #define VEC_OBJECT VecI32Object @@ -18,5 +17,3 @@ #define BUFFER_FORMAT "i" #include "vec_template.c" - -#endif // MYPYC_EXPERIMENTAL diff --git a/mypyc/lib-rt/vecs/vec_i64.c b/mypyc/lib-rt/vecs/vec_i64.c index 5e89d68f9bf6f..e496364688b76 100644 --- a/mypyc/lib-rt/vecs/vec_i64.c +++ b/mypyc/lib-rt/vecs/vec_i64.c @@ -1,4 +1,3 @@ -#ifdef MYPYC_EXPERIMENTAL #define VEC VecI64 #define VEC_TYPE VecI64Type #define VEC_OBJECT VecI64Object @@ -18,5 +17,3 @@ #define BUFFER_FORMAT "q" #include "vec_template.c" - -#endif // MYPYC_EXPERIMENTAL diff --git a/mypyc/lib-rt/vecs/vec_nested.c b/mypyc/lib-rt/vecs/vec_nested.c index 44de1c9e817be..c2f04ba8566e9 100644 --- a/mypyc/lib-rt/vecs/vec_nested.c +++ b/mypyc/lib-rt/vecs/vec_nested.c @@ -1,4 +1,3 @@ -#ifdef MYPYC_EXPERIMENTAL // Implementation of nested vec[t], when t is a vec type. // // Examples of types supported: @@ -764,5 +763,3 @@ VecNestedAPI Vec_NestedAPI = { VecNested_Extend, VecNested_ExtendVec, }; - -#endif // MYPYC_EXPERIMENTAL diff --git a/mypyc/lib-rt/vecs/vec_t.c b/mypyc/lib-rt/vecs/vec_t.c index 60201041584a8..3cfd1756201ce 100644 --- a/mypyc/lib-rt/vecs/vec_t.c +++ b/mypyc/lib-rt/vecs/vec_t.c @@ -1,4 +1,3 @@ -#ifdef MYPYC_EXPERIMENTAL // Implementation of generic vec[t], when t is a plain type object (possibly optional). // // Examples of types supported: @@ -838,5 +837,3 @@ VecTAPI Vec_TAPI = { VecT_ToList, VecT_ToTuple, }; - -#endif // MYPYC_EXPERIMENTAL diff --git a/mypyc/lib-rt/vecs/vec_template.c b/mypyc/lib-rt/vecs/vec_template.c index 97dd0bfa7a22f..b3e80261fec38 100644 --- a/mypyc/lib-rt/vecs/vec_template.c +++ b/mypyc/lib-rt/vecs/vec_template.c @@ -1,4 +1,3 @@ -#ifdef MYPYC_EXPERIMENTAL // NOTE: This file can't be compiled on its own, it must be #included // with certain #defines set, as described below. // @@ -821,5 +820,3 @@ NAME(API) FEATURES = { #undef VEC_CAP #undef VEC_INCREF #undef VEC_DECREF - -#endif // MYPYC_EXPERIMENTAL diff --git a/mypyc/lib-rt/vecs/vec_u8.c b/mypyc/lib-rt/vecs/vec_u8.c index f5c82824790fd..f2942689e95b6 100644 --- a/mypyc/lib-rt/vecs/vec_u8.c +++ b/mypyc/lib-rt/vecs/vec_u8.c @@ -1,4 +1,3 @@ -#ifdef MYPYC_EXPERIMENTAL #define VEC VecU8 #define VEC_TYPE VecU8Type #define VEC_OBJECT VecU8Object @@ -18,5 +17,3 @@ #define BUFFER_FORMAT "B" #include "vec_template.c" - -#endif // MYPYC_EXPERIMENTAL diff --git a/mypyc/lib-rt/vecs_extra_ops.c b/mypyc/lib-rt/vecs_extra_ops.c index 564eae2c9fcb5..a5da116c8a352 100644 --- a/mypyc/lib-rt/vecs_extra_ops.c +++ b/mypyc/lib-rt/vecs_extra_ops.c @@ -3,8 +3,4 @@ #include "vecs_extra_ops.h" -#ifdef MYPYC_EXPERIMENTAL - // All operations are currently implemented as inline functions in vecs_extra_ops.h - -#endif // MYPYC_EXPERIMENTAL diff --git a/mypyc/lib-rt/vecs_extra_ops.h b/mypyc/lib-rt/vecs_extra_ops.h index c7f0676d9df3c..4c31d7cd34488 100644 --- a/mypyc/lib-rt/vecs_extra_ops.h +++ b/mypyc/lib-rt/vecs_extra_ops.h @@ -1,8 +1,6 @@ #ifndef VECS_EXTRA_OPS_H #define VECS_EXTRA_OPS_H -#ifdef MYPYC_EXPERIMENTAL - #include "vecs/librt_vecs_api.h" // Check if obj is an instance of vec (any vec type) @@ -17,6 +15,4 @@ static inline PyObject *CPyVecU8_ToBytes(VecU8 v) { return PyBytes_FromStringAndSize((const char *)v.items, v.len); } -#endif // MYPYC_EXPERIMENTAL - #endif diff --git a/mypyc/primitives/librt_vecs_ops.py b/mypyc/primitives/librt_vecs_ops.py index 57769c77be929..e4852d5387069 100644 --- a/mypyc/primitives/librt_vecs_ops.py +++ b/mypyc/primitives/librt_vecs_ops.py @@ -16,7 +16,6 @@ return_type=bit_rprimitive, c_function_name="CPyVec_Check", error_kind=ERR_NEVER, - experimental=True, dependencies=[LIBRT_VECS, VECS_EXTRA_OPS], ) @@ -27,6 +26,5 @@ return_type=bytes_rprimitive, c_function_name="CPyVecU8_ToBytes", error_kind=ERR_MAGIC, - experimental=True, dependencies=[LIBRT_VECS, VECS_EXTRA_OPS], ) diff --git a/mypyc/test-data/capsule-deps.test b/mypyc/test-data/capsule-deps.test index 00252dd2de6ec..263e2a4b6ec40 100644 --- a/mypyc/test-data/capsule-deps.test +++ b/mypyc/test-data/capsule-deps.test @@ -79,7 +79,7 @@ def f() -> bytes: Capsule(name='librt.base64') Capsule(name='librt.strings') -[case testVecCapsuleDepInFunction_experimental] +[case testVecCapsuleDepInFunction] from librt.vecs import vec def f() -> None: @@ -87,7 +87,7 @@ def f() -> None: [out] Capsule(name='librt.vecs') -[case testVecCapsuleDepInMethod_experimental] +[case testVecCapsuleDepInMethod] from librt.vecs import vec class C: @@ -96,14 +96,14 @@ class C: [out] Capsule(name='librt.vecs') -[case testVecCapsuleDepAtTopLevel_experimental] +[case testVecCapsuleDepAtTopLevel] from librt.vecs import vec vec[str]() [out] Capsule(name='librt.vecs') -[case testVecCapsuleDepInAttributeType_experimental] +[case testVecCapsuleDepInAttributeType] from librt.vecs import vec class C: diff --git a/mypyc/test-data/irbuild-vec-misc.test b/mypyc/test-data/irbuild-vec-misc.test index 95d854780db98..c0d4325e38fcc 100644 --- a/mypyc/test-data/irbuild-vec-misc.test +++ b/mypyc/test-data/irbuild-vec-misc.test @@ -342,7 +342,7 @@ L0: x = r13 return x -[case testVecU8ToBytes_experimental] +[case testVecU8ToBytes] from librt.vecs import vec from mypy_extensions import u8 diff --git a/mypyc/test-data/run-vecs-i64-interp.test b/mypyc/test-data/run-vecs-i64-interp.test index 8f82d5cbaf6dc..113ae0154a8cd 100644 --- a/mypyc/test-data/run-vecs-i64-interp.test +++ b/mypyc/test-data/run-vecs-i64-interp.test @@ -1,4 +1,4 @@ -[case testLibrtVecsI64Interpreted_librt_experimental] +[case testLibrtVecsI64Interpreted_librt] # Test cases for vec[i64], using generic operations (simulates use from interpreted code). # # These also act as test cases for specialized vec types in general (e.g. vec[float]), diff --git a/mypyc/test-data/run-vecs-i64.test b/mypyc/test-data/run-vecs-i64.test index 97913d1321bdb..b8a74c96d6fb9 100644 --- a/mypyc/test-data/run-vecs-i64.test +++ b/mypyc/test-data/run-vecs-i64.test @@ -1,7 +1,7 @@ -- Test cases for vec[i64]. These also partially cover other unboxed item types, -- which use a similar runtime representation. -[case testVecI64BasicOps_librt_experimental] +[case testVecI64BasicOps_librt] from typing import Final, Any, Iterable, Tuple from mypy_extensions import i64, i32 diff --git a/mypyc/test-data/run-vecs-misc-interp.test b/mypyc/test-data/run-vecs-misc-interp.test index 443450c699c6d..e5158d4a1a316 100644 --- a/mypyc/test-data/run-vecs-misc-interp.test +++ b/mypyc/test-data/run-vecs-misc-interp.test @@ -1,4 +1,4 @@ -[case testLibrtVecsMiscInterpreted_librt_experimental] +[case testLibrtVecsMiscInterpreted_librt] # Test cases for vec[]. using generic operations. # This simulates use from interpreted code. # @@ -538,7 +538,7 @@ def test_extend_bool() -> None: v = extend(v, [False, True]) assert v == vec[bool]([True, False, True]) -[case testLibrtVecsBufferProtocol_librt_experimental] +[case testLibrtVecsBufferProtocol_librt] import struct from typing import Any @@ -639,14 +639,3 @@ def test_buffer_extend_from_shared_buffer() -> None: v = extend(old, memoryview_(new)) assert v == vec[u8]([1, 2, 1, 2, 3]) assert new == vec[u8]([1, 2, 3]) - -[case testLibrtVecsFeaturesNotAvailableInNonExperimentalBuild_librt] -# This also ensures librt.vecs can be built without experimental features -import librt.vecs - -def test_features_not_available() -> None: - vecs: object = getattr(librt, "vecs") - assert not hasattr(vecs, "vec") - assert not hasattr(vecs, "append") - assert not hasattr(vecs, "remove") - assert not hasattr(vecs, "pop") diff --git a/mypyc/test-data/run-vecs-misc.test b/mypyc/test-data/run-vecs-misc.test index 3a5de18690ba0..f3ebe11ff55e2 100644 --- a/mypyc/test-data/run-vecs-misc.test +++ b/mypyc/test-data/run-vecs-misc.test @@ -4,7 +4,7 @@ -- -- vec[i64] test cases are in run-vecs-i64.test. -[case testVecMiscBasicOps_librt_experimental] +[case testVecMiscBasicOps_librt] # mypy: allow-redefinition-old from typing import Any, Iterable, cast diff --git a/mypyc/test-data/run-vecs-nested-interp.test b/mypyc/test-data/run-vecs-nested-interp.test index 767d1188e9252..049e4dab9013b 100644 --- a/mypyc/test-data/run-vecs-nested-interp.test +++ b/mypyc/test-data/run-vecs-nested-interp.test @@ -1,4 +1,4 @@ -[case testLibrtVecsNestedInterpreted_librt_experimental] +[case testLibrtVecsNestedInterpreted_librt] # Test cases for nested vecs, using generic operations (simulates use from interpreted code). import sys diff --git a/mypyc/test-data/run-vecs-nested.test b/mypyc/test-data/run-vecs-nested.test index 7bfe06dbc408e..98a53e6e0bb6e 100644 --- a/mypyc/test-data/run-vecs-nested.test +++ b/mypyc/test-data/run-vecs-nested.test @@ -1,4 +1,4 @@ -[case testVecNestedBasicOps_librt_experimental] +[case testVecNestedBasicOps_librt] from typing import Final, Any, Iterable, Optional, Tuple import sys diff --git a/mypyc/test-data/run-vecs-t-interp.test b/mypyc/test-data/run-vecs-t-interp.test index a4ffdcb8d9f48..73077b5ef8938 100644 --- a/mypyc/test-data/run-vecs-t-interp.test +++ b/mypyc/test-data/run-vecs-t-interp.test @@ -1,4 +1,4 @@ -[case testLibrtVecsTInterpreted_librt_experimental] +[case testLibrtVecsTInterpreted_librt] # Test cases for vec[], using generic operations (simulates use from interpreted code). import sys from typing import cast, List, Any diff --git a/mypyc/test-data/run-vecs-t.test b/mypyc/test-data/run-vecs-t.test index 055438ced7ccd..50d1adbd51306 100644 --- a/mypyc/test-data/run-vecs-t.test +++ b/mypyc/test-data/run-vecs-t.test @@ -1,7 +1,7 @@ -- Test cases for vec[t] where t is a boxed, non-vec type (PyObject *). -- Also tests for vec[t | None], which uses the same representation. -[case testVecTBasicOps_librt_experimental] +[case testVecTBasicOps_librt] from typing import Final, Any, Iterable, Optional, Tuple from mypy_extensions import i64