Skip to content

Commit 6710142

Browse files
authored
[mypyc] librt.strings no longer behind experimental compiler flag (#21315)
It will be included in the default librt build, and the features can be used in compiled code without feature flags. It's still considered experimental from the functionality point of view, but not from the build system point of the view. We are still missing documentation. I'll prepare it in another PR.
1 parent 0653fa0 commit 6710142

12 files changed

Lines changed: 13 additions & 117 deletions

mypyc/lib-rt/byteswriter_extra_ops.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
#include "byteswriter_extra_ops.h"
55

6-
#ifdef MYPYC_EXPERIMENTAL
7-
86
char CPyBytesWriter_Write(PyObject *obj, PyObject *value) {
97
BytesWriterObject *self = (BytesWriterObject *)obj;
108
const char *data;
@@ -41,5 +39,3 @@ void CPyBytes_ReadError(int64_t index, Py_ssize_t size) {
4139
(long long)index, size);
4240
}
4341
}
44-
45-
#endif // MYPYC_EXPERIMENTAL

mypyc/lib-rt/byteswriter_extra_ops.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#ifndef BYTESWRITER_EXTRA_OPS_H
22
#define BYTESWRITER_EXTRA_OPS_H
33

4-
#ifdef MYPYC_EXPERIMENTAL
5-
64
#include <stdbool.h>
75
#include <stdint.h>
86
#include <Python.h>
@@ -286,6 +284,4 @@ CPyBytes_ReadF64BE(PyObject *bytes_obj, int64_t index) {
286284
return CPyBytes_ReadF64BEUnsafe(data + index);
287285
}
288286

289-
#endif // MYPYC_EXPERIMENTAL
290-
291287
#endif

mypyc/lib-rt/strings/librt_strings.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
((BytesWriterObject *)data)->len += sizeof(type); \
1919
} while (0)
2020

21-
#ifdef MYPYC_EXPERIMENTAL
22-
2321
static PyTypeObject BytesWriterType;
2422

2523
static bool
@@ -1155,10 +1153,7 @@ read_f64_be(PyObject *module, PyObject *const *args, size_t nargs) {
11551153
return PyFloat_FromDouble(CPyBytes_ReadF64BEUnsafe(data + index));
11561154
}
11571155

1158-
#endif
1159-
11601156
static PyMethodDef librt_strings_module_methods[] = {
1161-
#ifdef MYPYC_EXPERIMENTAL
11621157
{"write_i16_le", (PyCFunction) write_i16_le, METH_FASTCALL,
11631158
PyDoc_STR("Write a 16-bit signed integer to BytesWriter in little-endian format")
11641159
},
@@ -1219,12 +1214,9 @@ static PyMethodDef librt_strings_module_methods[] = {
12191214
{"read_f64_be", (PyCFunction) read_f64_be, METH_FASTCALL,
12201215
PyDoc_STR("Read a 64-bit float from bytes in big-endian format")
12211216
},
1222-
#endif
12231217
{NULL, NULL, 0, NULL}
12241218
};
12251219

1226-
#ifdef MYPYC_EXPERIMENTAL
1227-
12281220
static int
12291221
strings_abi_version(void) {
12301222
return LIBRT_STRINGS_ABI_VERSION;
@@ -1235,12 +1227,9 @@ strings_api_version(void) {
12351227
return LIBRT_STRINGS_API_VERSION;
12361228
}
12371229

1238-
#endif
1239-
12401230
static int
12411231
librt_strings_module_exec(PyObject *m)
12421232
{
1243-
#ifdef MYPYC_EXPERIMENTAL
12441233
if (PyType_Ready(&BytesWriterType) < 0) {
12451234
return -1;
12461235
}
@@ -1275,7 +1264,6 @@ librt_strings_module_exec(PyObject *m)
12751264
if (PyModule_Add(m, "_C_API", c_api_object) < 0) {
12761265
return -1;
12771266
}
1278-
#endif
12791267
return 0;
12801268
}
12811269

mypyc/lib-rt/strings/librt_strings.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#ifndef LIBRT_STRINGS_H
22
#define LIBRT_STRINGS_H
33

4-
#ifdef MYPYC_EXPERIMENTAL
5-
64
#include <stdbool.h>
75
#include <Python.h>
86
#include "librt_strings_common.h"
@@ -30,6 +28,4 @@ typedef struct {
3028
char data[WRITER_EMBEDDED_BUF_LEN]; // Default buffer
3129
} StringWriterObject;
3230

33-
#endif // MYPYC_EXPERIMENTAL
34-
3531
#endif // LIBRT_STRINGS_H

mypyc/lib-rt/strings/librt_strings_api.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
#include "librt_strings_api.h"
22

3-
#ifndef MYPYC_EXPERIMENTAL
4-
5-
int
6-
import_librt_strings(void)
7-
{
8-
// All librt.strings features are experimental for now, so don't set up the API here
9-
return 0;
10-
}
11-
12-
#else // MYPYC_EXPERIMENTAL
13-
143
void *LibRTStrings_API[LIBRT_STRINGS_API_LEN] = {0};
154

165
int
@@ -52,5 +41,3 @@ import_librt_strings(void)
5241
memcpy(LibRTStrings_API, capsule, sizeof(LibRTStrings_API));
5342
return 0;
5443
}
55-
56-
#endif // MYPYC_EXPERIMENTAL

mypyc/lib-rt/strings/librt_strings_api.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
int
55
import_librt_strings(void);
66

7-
#ifdef MYPYC_EXPERIMENTAL
8-
97
#include <stdbool.h>
108
#include <Python.h>
119
#include "librt_strings.h"
@@ -36,6 +34,4 @@ static inline bool CPyStringWriter_Check(PyObject *obj) {
3634
return Py_TYPE(obj) == LibRTStrings_StringWriter_type_internal();
3735
}
3836

39-
#endif // MYPYC_EXPERIMENTAL
40-
4137
#endif // LIBRT_STRINGS_API_H

mypyc/lib-rt/stringwriter_extra_ops.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,5 @@
33

44
#include "stringwriter_extra_ops.h"
55

6-
#ifdef MYPYC_EXPERIMENTAL
7-
86
// All StringWriter operations are currently implemented as inline functions
97
// in stringwriter_extra_ops.h, or use the exported capsule API directly.
10-
11-
#endif // MYPYC_EXPERIMENTAL

mypyc/lib-rt/stringwriter_extra_ops.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#ifndef STRINGWRITER_EXTRA_OPS_H
22
#define STRINGWRITER_EXTRA_OPS_H
33

4-
#ifdef MYPYC_EXPERIMENTAL
5-
64
#include <stdbool.h>
75
#include <stdint.h>
86
#include <Python.h>
@@ -74,6 +72,4 @@ static inline int32_t CPyStringWriter_GetItem(PyObject *obj, int64_t index) {
7472
}
7573
}
7674

77-
#endif // MYPYC_EXPERIMENTAL
78-
7975
#endif

0 commit comments

Comments
 (0)