diff --git a/docs/modules/line_profiler.md b/docs/modules/line_profiler.md deleted file mode 100644 index d0d1ea91..00000000 --- a/docs/modules/line_profiler.md +++ /dev/null @@ -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 -``` \ No newline at end of file diff --git a/include/pocketpy/config.h b/include/pocketpy/config.h index 1aab93df..5876052e 100644 --- a/include/pocketpy/config.h +++ b/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 \ No newline at end of file diff --git a/include/pocketpy/pocketpy.h b/include/pocketpy/pocketpy.h index 1f7b0393..f48a946a 100644 --- a/include/pocketpy/pocketpy.h +++ b/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; diff --git a/src/interpreter/ceval.c b/src/interpreter/ceval.c index 1c53063c..f73d9a3a 100644 --- a/src/interpreter/ceval.c +++ b/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 diff --git a/src/public/internal.c b/src/public/internal.c index b5e6037d..0480388e 100644 --- a/src/public/internal.c +++ b/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()); diff --git a/src2/main.c b/src2/main.c index ccc47930..7a779683 100644 --- a/src2/main.c +++ b/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");