diff --git a/library/_builtins.py b/library/_builtins.py index 25b5ed3b2..049dcf2d1 100644 --- a/library/_builtins.py +++ b/library/_builtins.py @@ -1002,6 +1002,7 @@ def _slice_start_long(start, step, length): def _slice_step(step): + "$intrinsic$" _builtin() diff --git a/runtime/under-builtins-module.cpp b/runtime/under-builtins-module.cpp index 85d2de346..26c55cc96 100644 --- a/runtime/under-builtins-module.cpp +++ b/runtime/under-builtins-module.cpp @@ -4570,6 +4570,21 @@ RawObject FUNC(_builtins, _slice_start_long)(Thread* thread, Arguments args) { return *start; } +bool FUNC(_builtins, _slice_step_intrinsic)(Thread* thread) { + RawObject step_obj = thread->stackTop(); + if (step_obj.isNoneType()) { + thread->stackPop(); + thread->stackSetTop(SmallInt::fromWord(1)); + return true; + } + if (step_obj.isSmallInt()) { + thread->stackPop(); + thread->stackSetTop(step_obj); + return true; + } + return false; +} + RawObject FUNC(_builtins, _slice_step)(Thread* thread, Arguments args) { RawObject step_obj = args.get(0); if (step_obj.isNoneType()) return SmallInt::fromWord(1);