From 3278699d030ab48f1167dd66a10b18c0d5f163aa Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Fri, 3 May 2024 17:41:01 +0800 Subject: [PATCH] remove `operator` module --- docs/modules/operator.md | 14 -------------- include/pocketpy/modules.h | 1 - src/modules.cpp | 10 ---------- src/pocketpy.cpp | 1 - 4 files changed, 26 deletions(-) delete mode 100644 docs/modules/operator.md diff --git a/docs/modules/operator.md b/docs/modules/operator.md deleted file mode 100644 index 02fabcca..00000000 --- a/docs/modules/operator.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -icon: package -label: operator ---- - -The operator module exports a set of efficient functions corresponding to the intrinsic operators of Python. For example, `operator.add(x, y)` is equivalent to the expression `x+y`. -Many function names are those used for special methods, without the double underscores. - -+ `operator.lt(a, b)` -+ `operator.le(a, b)` -+ `operator.eq(a, b)` -+ `operator.ne(a, b)` -+ `operator.ge(a, b)` -+ `operator.gt(a, b)` \ No newline at end of file diff --git a/include/pocketpy/modules.h b/include/pocketpy/modules.h index 9975bf53..342aa006 100644 --- a/include/pocketpy/modules.h +++ b/include/pocketpy/modules.h @@ -4,7 +4,6 @@ namespace pkpy{ -void add_module_operator(VM* vm); void add_module_time(VM* vm); void add_module_sys(VM* vm); void add_module_json(VM* vm); diff --git a/src/modules.cpp b/src/modules.cpp index c05ec448..196a11ec 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -2,16 +2,6 @@ namespace pkpy{ -void add_module_operator(VM* vm){ - PyObject* mod = vm->new_module("operator"); - vm->bind_func<2>(mod, "lt", [](VM* vm, ArgsView args) { return VAR(vm->py_lt(args[0], args[1]));}); - vm->bind_func<2>(mod, "le", [](VM* vm, ArgsView args) { return VAR(vm->py_le(args[0], args[1]));}); - vm->bind_func<2>(mod, "eq", [](VM* vm, ArgsView args) { return VAR(vm->py_eq(args[0], args[1]));}); - vm->bind_func<2>(mod, "ne", [](VM* vm, ArgsView args) { return VAR(vm->py_ne(args[0], args[1]));}); - vm->bind_func<2>(mod, "ge", [](VM* vm, ArgsView args) { return VAR(vm->py_ge(args[0], args[1]));}); - vm->bind_func<2>(mod, "gt", [](VM* vm, ArgsView args) { return VAR(vm->py_gt(args[0], args[1]));}); -} - struct PyStructTime{ int tm_year; int tm_mon; diff --git a/src/pocketpy.cpp b/src/pocketpy.cpp index 323e4ef1..ceee885e 100644 --- a/src/pocketpy.cpp +++ b/src/pocketpy.cpp @@ -1611,7 +1611,6 @@ void VM::post_init(){ add_module_gc(this); add_module_random(this); add_module_base64(this); - add_module_operator(this); _lazy_modules["this"] = kPythonLibs_this; _lazy_modules["functools"] = kPythonLibs_functools;