blueloveTH 1 год назад
Родитель
Сommit
19563e33d2

+ 0 - 41
docs/modules/line_profiler.md

@@ -1,41 +0,0 @@
----
-icon: package
-label: line_profiler
----
-
-!!!
-This module is optional. Set `PK_ENABLE_PROFILER` to `1` to enable it.
-!!!
-
-## Example
-
-```python
-from line_profiler import LineProfiler
-
-def my_func():
-    a = 0
-    for i in range(1000000):
-        a += i
-    return a
-
-lp = LineProfiler()
-
-lp.add_function(my_func)
-
-lp.runcall(my_func)
-
-lp.print_stats()
-```
-
-```txt
-Total time: 0.243s
-File: 84_line_profiler.py
-Function: my_func at line 3
-Line #      Hits         Time  Per Hit   % Time  Line Contents
-==============================================================
-     3                                           def my_func():
-     4         1            0        0      0.0      a = 0
-     5   1000001           69        0     28.4      for i in range(1000000):
-     6   1000001          174        0     71.6          a += i
-     7         1            0        0      0.0      return a
-```

+ 0 - 11
include/pocketpy/config.h

@@ -13,11 +13,6 @@
 #define PK_ENABLE_OS                1
 #endif
 
-// Enable `line_profiler` module and `breakpoint()` function
-#ifndef PK_ENABLE_PROFILER          // can be overridden by cmake
-#define PK_ENABLE_PROFILER          0
-#endif
-
 // GC min threshold
 #ifndef PK_GC_MIN_THRESHOLD         // can be overridden by cmake
 #define PK_GC_MIN_THRESHOLD         16384
@@ -45,10 +40,4 @@
     #define PK_PLATFORM_SEP '\\'
 #else
     #define PK_PLATFORM_SEP '/'
-#endif
-
-#ifdef NDEBUG
-    #define PK_DEBUG 0
-#else
-    #define PK_DEBUG 1
 #endif

+ 1 - 1
include/pocketpy/pocketpy.h

@@ -548,7 +548,7 @@ PK_EXPORT bool py_isidentical(py_Ref, py_Ref);
 /// The stack remains unchanged after the operation.
 PK_EXPORT bool py_call(py_Ref f, int argc, py_Ref argv) PY_RAISE PY_RETURN;
 
-#if PK_DEBUG
+#ifndef NDEBUG
 /// Call a `py_CFunction` in a safe way.
 /// This function does extra checks to help you debug `py_CFunction`.
 PK_EXPORT bool py_callcfunc(py_CFunction f, int argc, py_Ref argv) PY_RAISE PY_RETURN;

+ 1 - 1
src/interpreter/ceval.c

@@ -87,7 +87,7 @@ FrameResult VM__run_top_frame(VM* self) {
     __NEXT_STEP:
         byte = *frame->ip;
 
-#if PK_DEBUG
+#ifndef NDEBUG
         pk_print_stack(self, frame, byte);
         // assert(!py_checkexc(true));
 #endif

+ 1 - 1
src/public/internal.c

@@ -118,7 +118,7 @@ bool py_call(py_Ref f, int argc, py_Ref argv) {
     }
 }
 
-#if PK_DEBUG
+#ifndef NDEBUG
 bool py_callcfunc(py_CFunction f, int argc, py_Ref argv) {
     py_StackRef p0 = py_peek(0);
     py_newnil(py_retval());

+ 1 - 1
src2/main.c

@@ -43,7 +43,7 @@ int main(int argc, char** argv) {
     if(argc == 1) {
         printf("pocketpy " PK_VERSION " (" __DATE__ ", " __TIME__ ") ");
         printf("[%d bit] on %s", (int)(sizeof(void*) * 8), PY_SYS_PLATFORM_STRING);
-#if PK_DEBUG
+#ifndef NDEBUG
         printf(" (DEBUG)");
 #endif
         printf("\n");