HOME

TheInfoList



OR:

Stackless Python, or Stackless, was a Python programming language interpreter. Its Github repository has been archived since February 2025, and the project has been officially discontinued. It was so named because it avoids depending on the C
call stack In computer science, a call stack is a Stack (abstract data type), stack data structure that stores information about the active subroutines and block (programming), inline blocks of a computer program. This type of stack is also known as an exe ...
for its own stack. In practice, Stackless Python uses the C stack, but the stack is cleared between function calls. The most prominent feature of Stackless is microthreads, which avoid much of the overhead associated with usual operating system threads. In addition to Python features, Stackless also adds support for
coroutine Coroutines are computer program components that allow execution to be suspended and resumed, generalizing subroutines for cooperative multitasking. Coroutines are well-suited for implementing familiar program components such as cooperative task ...
s, communication channels, and task
serialization In computing, serialization (or serialisation, also referred to as pickling in Python (programming language), Python) is the process of translating a data structure or object (computer science), object state into a format that can be stored (e. ...
.


Design

With Stackless Python, a running program is split into microthreads that are managed by the language interpreter itself, not the operating system kernelcontext switching and
task scheduling In computing, scheduling is the action of assigning resources to perform tasks. The resources may be processors, network links or expansion cards. The tasks may be threads, processes or data flows. The scheduling activity is carried out by ...
is done purely in the interpreter (these are thus also regarded as a form of green thread). Microthreads manage the execution of different subtasks in a program on the same CPU core. Thus, they are an alternative to event-based asynchronous programming and also avoid the overhead of using separate threads for single-core programs (because no mode switching between user mode and kernel mode needs to be done, so CPU usage can be reduced). Although microthreads make it easier to deal with running subtasks on a single core, Stackless Python does not remove CPython's
global interpreter lock A global interpreter lock (GIL) is a mechanism used in computer-language Interpreter (computing), interpreters to synchronize the execution of Threads (computer science), threads so that only one native thread (per process) can execute basic ope ...
(GIL), nor does it use multiple threads and/or processes. So it allows only
cooperative multitasking Cooperative multitasking, also known as non-preemptive multitasking, is a computer multitasking technique in which the operating system never initiates a context switch from a running Process (computing), process to another process. Instead, in o ...
on a shared CPU and not parallelism (preemption was originally not available but is now in some form). To use multiple CPU cores, one would still need to build an interprocess communication system on top of Stackless Python processes. Due to the considerable number of changes in the source, Stackless Python cannot be installed on a preexisting Python installation as an extension or
library A library is a collection of Book, books, and possibly other Document, materials and Media (communication), media, that is accessible for use by its members and members of allied institutions. Libraries provide physical (hard copies) or electron ...
. It is instead a complete Python distribution in itself. The majority of Stackless's features have also been implemented in PyPy, a self-hosting Python interpreter and
JIT compiler In computing, just-in-time (JIT) compilation (also dynamic translation or run-time compilations) is compiler, compilation (of Source code, computer code) during execution of a program (at run time (program lifecycle phase), run time) rather than b ...
.


Use

Although the whole Stackless is a separate distribution, its switching functionality has been successfully packaged as a
CPython CPython is the reference implementation of the Python programming language. Written in C and Python, CPython is the default and most widely used implementation of the Python language. CPython can be defined as both an interpreter and a comp ...
extension called greenlet. It is used by a number of libraries (e.g. gevent) to provide a green threading solution for CPython. Python since has received a native solution for green threads: await/async. Stackless is used extensively in the implementation of the '' Eve Online'' massively multiplayer online game as well as in IronPort's mail platform.


See also

*
Erlang (programming language) Erlang ( ) is a general-purpose, concurrent, functional high-level programming language, and a garbage-collected runtime system. The term Erlang is used interchangeably with Erlang/OTP, or Open Telecom Platform (OTP), which consists of the ...
*
Limbo (programming language) Limbo is a programming language for writing distributed systems and is the language used to write applications for the Inferno operating system. It was designed at Bell Labs by Sean Dorward, Phil Winterbottom, and Rob Pike. The Limbo compi ...
*
Go (programming language) Go is a high-level programming language, high-level general purpose programming language that is static typing, statically typed and compiled language, compiled. It is known for the simplicity of its syntax and the efficiency of development th ...
* SCOOP (software)


References


External links

* * Stackless Python Documentation for
3.7-slp
*
Multithreaded Game Scripting with Stackless Python
by Harry Kalogirou

by Christian Tismer {{Python (programming language) Concurrent computing Python (programming language) implementations Software using the Python Software Foundation License