Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions mypyc/lib-rt/vecs/librt_vecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@
#include <Python.h>
#include "librt_vecs.h"

#ifdef MYPYC_EXPERIMENTAL

PyTypeObject *LibRTVecs_I64TypeObj;
PyTypeObject *LibRTVecs_I32TypeObj;
PyTypeObject *LibRTVecs_I16TypeObj;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1109,7 +1102,6 @@ librt_vecs_module_exec(PyObject *m)
}

Py_DECREF(ext);
#endif
return 0;
}

Expand Down
4 changes: 0 additions & 4 deletions mypyc/lib-rt/vecs/librt_vecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
13 changes: 0 additions & 13 deletions mypyc/lib-rt/vecs/librt_vecs_api.c
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -60,5 +49,3 @@ import_librt_vecs(void)
VecNestedApi = *VecApi->nested;
return 0;
}

#endif // MYPYC_EXPERIMENTAL
4 changes: 0 additions & 4 deletions mypyc/lib-rt/vecs/librt_vecs_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,6 +21,4 @@ extern VecBoolAPI VecBoolApi;
extern VecTAPI VecTApi;
extern VecNestedAPI VecNestedApi;

#endif // MYPYC_EXPERIMENTAL

#endif // LIBRT_VECS_API_H
3 changes: 0 additions & 3 deletions mypyc/lib-rt/vecs/vec_bool.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#ifdef MYPYC_EXPERIMENTAL
#define VEC VecBool
#define VEC_TYPE VecBoolType
#define VEC_OBJECT VecBoolObject
Expand All @@ -17,5 +16,3 @@
#define BUFFER_FORMAT "b"

#include "vec_template.c"

#endif // MYPYC_EXPERIMENTAL
3 changes: 0 additions & 3 deletions mypyc/lib-rt/vecs/vec_float.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#ifdef MYPYC_EXPERIMENTAL
#define VEC VecFloat
#define VEC_TYPE VecFloatType
#define VEC_OBJECT VecFloatObject
Expand All @@ -18,5 +17,3 @@
#define BUFFER_FORMAT "d"

#include "vec_template.c"

#endif // MYPYC_EXPERIMENTAL
3 changes: 0 additions & 3 deletions mypyc/lib-rt/vecs/vec_i16.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#ifdef MYPYC_EXPERIMENTAL
#define VEC VecI16
#define VEC_TYPE VecI16Type
#define VEC_OBJECT VecI16Object
Expand All @@ -18,5 +17,3 @@
#define BUFFER_FORMAT "h"

#include "vec_template.c"

#endif // MYPYC_EXPERIMENTAL
3 changes: 0 additions & 3 deletions mypyc/lib-rt/vecs/vec_i32.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#ifdef MYPYC_EXPERIMENTAL
#define VEC VecI32
#define VEC_TYPE VecI32Type
#define VEC_OBJECT VecI32Object
Expand All @@ -18,5 +17,3 @@
#define BUFFER_FORMAT "i"

#include "vec_template.c"

#endif // MYPYC_EXPERIMENTAL
3 changes: 0 additions & 3 deletions mypyc/lib-rt/vecs/vec_i64.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#ifdef MYPYC_EXPERIMENTAL
#define VEC VecI64
#define VEC_TYPE VecI64Type
#define VEC_OBJECT VecI64Object
Expand All @@ -18,5 +17,3 @@
#define BUFFER_FORMAT "q"

#include "vec_template.c"

#endif // MYPYC_EXPERIMENTAL
3 changes: 0 additions & 3 deletions mypyc/lib-rt/vecs/vec_nested.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#ifdef MYPYC_EXPERIMENTAL
// Implementation of nested vec[t], when t is a vec type.
//
// Examples of types supported:
Expand Down Expand Up @@ -764,5 +763,3 @@ VecNestedAPI Vec_NestedAPI = {
VecNested_Extend,
VecNested_ExtendVec,
};

#endif // MYPYC_EXPERIMENTAL
3 changes: 0 additions & 3 deletions mypyc/lib-rt/vecs/vec_t.c
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -838,5 +837,3 @@ VecTAPI Vec_TAPI = {
VecT_ToList,
VecT_ToTuple,
};

#endif // MYPYC_EXPERIMENTAL
3 changes: 0 additions & 3 deletions mypyc/lib-rt/vecs/vec_template.c
Original file line number Diff line number Diff line change
@@ -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.
//
Expand Down Expand Up @@ -821,5 +820,3 @@ NAME(API) FEATURES = {
#undef VEC_CAP
#undef VEC_INCREF
#undef VEC_DECREF

#endif // MYPYC_EXPERIMENTAL
3 changes: 0 additions & 3 deletions mypyc/lib-rt/vecs/vec_u8.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#ifdef MYPYC_EXPERIMENTAL
#define VEC VecU8
#define VEC_TYPE VecU8Type
#define VEC_OBJECT VecU8Object
Expand All @@ -18,5 +17,3 @@
#define BUFFER_FORMAT "B"

#include "vec_template.c"

#endif // MYPYC_EXPERIMENTAL
4 changes: 0 additions & 4 deletions mypyc/lib-rt/vecs_extra_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 0 additions & 4 deletions mypyc/lib-rt/vecs_extra_ops.h
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -17,6 +15,4 @@ static inline PyObject *CPyVecU8_ToBytes(VecU8 v) {
return PyBytes_FromStringAndSize((const char *)v.items, v.len);
}

#endif // MYPYC_EXPERIMENTAL

#endif
2 changes: 0 additions & 2 deletions mypyc/primitives/librt_vecs_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
)

Expand All @@ -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],
)
8 changes: 4 additions & 4 deletions mypyc/test-data/capsule-deps.test
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ def f() -> bytes:
Capsule(name='librt.base64')
Capsule(name='librt.strings')

[case testVecCapsuleDepInFunction_experimental]
[case testVecCapsuleDepInFunction]
from librt.vecs import vec

def f() -> None:
vec[str]()
[out]
Capsule(name='librt.vecs')

[case testVecCapsuleDepInMethod_experimental]
[case testVecCapsuleDepInMethod]
from librt.vecs import vec

class C:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion mypyc/test-data/irbuild-vec-misc.test
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ L0:
x = r13
return x

[case testVecU8ToBytes_experimental]
[case testVecU8ToBytes]
from librt.vecs import vec
from mypy_extensions import u8

Expand Down
2 changes: 1 addition & 1 deletion mypyc/test-data/run-vecs-i64-interp.test
Original file line number Diff line number Diff line change
@@ -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]),
Expand Down
2 changes: 1 addition & 1 deletion mypyc/test-data/run-vecs-i64.test
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 2 additions & 13 deletions mypyc/test-data/run-vecs-misc-interp.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[case testLibrtVecsMiscInterpreted_librt_experimental]
[case testLibrtVecsMiscInterpreted_librt]
# Test cases for vec[<value primitive type>]. using generic operations.
# This simulates use from interpreted code.
#
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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")
2 changes: 1 addition & 1 deletion mypyc/test-data/run-vecs-misc.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mypyc/test-data/run-vecs-nested-interp.test
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion mypyc/test-data/run-vecs-nested.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[case testVecNestedBasicOps_librt_experimental]
[case testVecNestedBasicOps_librt]
from typing import Final, Any, Iterable, Optional, Tuple
import sys

Expand Down
2 changes: 1 addition & 1 deletion mypyc/test-data/run-vecs-t-interp.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[case testLibrtVecsTInterpreted_librt_experimental]
[case testLibrtVecsTInterpreted_librt]
# Test cases for vec[<ref type>], using generic operations (simulates use from interpreted code).
import sys
from typing import cast, List, Any
Expand Down
2 changes: 1 addition & 1 deletion mypyc/test-data/run-vecs-t.test
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading