{"id":13605325,"url":"https://github.com/pfalcon/pycopy","last_synced_at":"2025-12-16T20:45:15.992Z","repository":{"id":12832188,"uuid":"15507576","full_name":"pfalcon/pycopy","owner":"pfalcon","description":"Pycopy - a minimalist and memory-efficient Python dialect. Good for desktop, cloud, constrained systems, microcontrollers, and just everything.","archived":false,"fork":false,"pushed_at":"2024-02-06T21:00:13.000Z","size":50300,"stargazers_count":805,"open_issues_count":28,"forks_count":76,"subscribers_count":33,"default_branch":"master","last_synced_at":"2024-10-29T17:12:42.177Z","etag":null,"topics":["embedded","iot","micropython","micropython-ports","minimalist","minimalistic","pycopy","python","suckless","unbloated"],"latest_commit_sha":null,"homepage":"http://pycopy.readthedocs.io","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pfalcon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-12-29T11:38:47.000Z","updated_at":"2024-10-26T09:57:38.000Z","dependencies_parsed_at":"2024-08-01T19:53:31.719Z","dependency_job_id":null,"html_url":"https://github.com/pfalcon/pycopy","commit_stats":null,"previous_names":[],"tags_count":105,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfalcon%2Fpycopy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfalcon%2Fpycopy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfalcon%2Fpycopy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfalcon%2Fpycopy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pfalcon","download_url":"https://codeload.github.com/pfalcon/pycopy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247856544,"owners_count":21007621,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["embedded","iot","micropython","micropython-ports","minimalist","minimalistic","pycopy","python","suckless","unbloated"],"created_at":"2024-08-01T19:00:57.405Z","updated_at":"2025-10-07T21:57:12.779Z","avatar_url":"https://github.com/pfalcon.png","language":"C","readme":"[![Build Status](https://github.com/pfalcon/pycopy/actions/workflows/ports_unix.yml/badge.svg)](https://github.com/pfalcon/pycopy/actions) [![Coverage Status](https://coveralls.io/repos/pfalcon/pycopy/badge.png?branch=master)](https://coveralls.io/github/pfalcon/pycopy?branch=master)\n\nThe Pycopy project\n==================\n\n[Web site](https://pycopy.github.io/) | [Documentation](https://pycopy.readthedocs.io/)\n\nPycopy aims to develop and maintain a **minimalist**, lightweight,\nand extensible implementation of\n[Python](https://en.wikipedia.org/wiki/Python_(programming_language))(-compatible)\nlanguage. Pycopy to CPython is a similar thing as\n[Scheme](https://en.wikipedia.org/wiki/Scheme_(programming_language))\nto [Common Lisp](https://en.wikipedia.org/wiki/Common_Lisp).\nPycopy works similarly well in the cloud, on desktop systems, on small\nembedded systems, and scales all the way down to microcontrollers. The\nproject is developed and maintained by Paul Sokolovsky and is originally\nbased on MicroPython, developed by Damien George, Paul Sokolovsky and\ncontributors. Names \"Pycopy\" and \"MicroPython\" are used interchangeably\nin the project documentation and source code.\n\nWARNING: this project is in beta stage and is subject to changes of the\ncode-base, including project-wide name changes and API changes.\n\nPycopy implements the entire Python 3.4 syntax (including exceptions,\n`with`, `yield from`, etc., and additionally `async`/`await` keywords from\nPython 3.5). The following core datatypes are provided: `str` (including\nbasic Unicode support), `bytes`, `bytearray`, `tuple`, `list`, `dict`, `set`,\n`frozenset`, `array.array`, `collections.namedtuple`, classes and instances.\nBuiltin modules include `sys`, `time`, and `struct`, etc. Select ports have\nsupport for `_thread` module (multithreading). Note that only a subset of\nPython 3 functionality is implemented for the data types and modules.\n\nPycopy can execute scripts in textual source form or from precompiled\nbytecode, in both cases either from an on-device filesystem or \"frozen\" into\nthe executable.\n\nPycopy is highly portable, and the main repository includes support for\nPOSIX operating systems (Linux, MacOSX, FreeBSD, etc.), Windows, Android,\nand a number of bare-metal microcontroller systems (see below). Ports to\nother systems can be implemented easily. POSIX port (nicknamed \"Unix port\")\nis the reference port of Pycopy.\n\nThe Pycopy Zen\n--------------\n\n[Just as \"big Python\"](https://www.python.org/dev/peps/pep-0020/), Pycopy has\nits \"Zen\". The main principles of Pycopy are **simplicity**, **minimalism**,\nand **light-weightedness**.\n\nAt the same time, Pycopy strives to be a full-stack language and\nbe compatible with wider Python ecosystem. The Pycopy project resolves\nthese seemingly conflicting goals in a well-known and elegant way: by\nbeing a multi-level project, and by providing flexible configuration options.\nSpecifically, there's a well-defined lightweight core written in C,\ndefining the \"native Pycopy language\". Above it, a number of options are\nprovided, implementing additional functionality (oftentimes offering more\nCPython compatibility). For example, on top of the core, \"native Pycopy\nbuiltin modules\" are provided, defining the native Pycopy API, which\nprovides a subset of CPython's modules functionality, and at the same time,\nsome extensions to it (driven by Pycopy's goal to be efficient). These native\nPycopy modules are clearly namespaced, to allow to implement modules fully\ncompatible with CPython API without any changes to the main project.\n\nOn top of this primary project, there are separate projects to further extend\nPycopy functionality and achieve full-stack ecosystem. For example, there's\na [pycopy-lib](https://github.com/pfalcon/pycopy-lib) project (see below) to\nimplement a fully compatible CPython standard library for Pycopy.\n\nFinally, on top of that infrastructure, there is an ecosystem of third-party\npackages, which are managed by the Pycopy users themselves.\n\nThe art of working with Pycopy is to understand where a particular feature\nbelongs. Just as with CPython, it's almost never the core project, and almost\nalways users' third party packages.\n\n[Contributors' Guidelines](https://github.com/pfalcon/pycopy/wiki/ContributorGuidelines)\nfurther elaborate on some points touched above.\n\nSource tree layout\n------------------\n\nMajor components in this repository:\n- [py/](py/) -- the core Python implementation, including compiler, runtime, and\n  core library.\n- [mpy-cross/](mpy-cross/) -- the bytecode (cross)compiler which is used to turn scripts\n  into precompiled bytecode.\n- [ports/unix/](ports/unix/) -- a version of Pycopy that runs on Unix (which includes Android).\n- [ports/windows/](ports/windows/) -- a version for Windows.\n- [ports/stm32/](ports/stm32/) -- a version of Pycopy that runs on the PyBoard and similar\n  STM32 boards (using ST's Cube HAL drivers).\n- [ports/minimal/](ports/minimal/) -- a minimal port. Start with this if you want\n  to port the project to another microcontroller.\n- [tests/](tests/) -- test framework and test scripts.\n- [docs/](docs/) -- user documentation in Sphinx reStructuredText format. Rendered\n  HTML documentation is available at http://pycopy.readthedocs.io/ .\n\nAdditional components:\n- [ports/bare-arm/](ports/bare-arm/) -- a bare minimum version for ARM MCUs. Used\n  mostly to control code size.\n- [ports/teensy/](ports/teensy/) -- a version that runs on the Teensy 3.1\n  (preliminary but functional).\n- [ports/pic16bit/](ports/pic16bit/) -- a version for 16-bit PIC microcontrollers.\n- [ports/cc3200/](ports/cc3200/) -- a version that runs on the CC3200 from TI.\n- [ports/esp8266/](ports/esp8266/) -- a version that runs on Espressif's ESP8266 SoC.\n- [ports/esp32/](ports/esp32/) -- a version that runs on Espressif's ESP32 SoC.\n- [ports/nrf/](ports/nrf/) -- a version that runs on Nordic's nRF51 and nRF52 MCUs.\n- [extmod/](extmod/) -- additional (non-core) modules implemented in C.\n- [tools/](tools/) -- various tools, including the pyboard.py module.\n- [examples/](examples/) -- various example scripts.\n\nThe subdirectories above may include READMEs with additional info.\n\n\"make\" is used to build the components, or \"gmake\" on BSD-based systems.\nYou will also need bash, gcc, and Python 3.3+ available as the command `python3`\n(if your system only has Python 2.7 then invoke make with the additional option\n`PYTHON=python2`).\n\nThe cross-compiler, pycopy-cross\n--------------------------------\n\nMost ports require the Pycopy cross-compiler to be built first.  This\nprogram, called pycopy-cross, is used to pre-compile Python scripts to .mpy\nfiles which can then be included (frozen) into the firmware/executable for\na port.  To build pycopy-cross use:\n\n    $ cd mpy-cross\n    $ make\n\nThe Unix version\n----------------\n\nThe \"unix\" port requires a standard Unix environment with gcc and GNU make.\nx86 and x64 architectures are supported (i.e. x86 32- and 64-bit), as well\nas ARM and MIPS. Making full-featured port to another architecture requires\nwriting some assembly code for the exception handling and garbage collection.\nAlternatively, fallback implementation based on setjmp/longjmp can be used.\n\nTo build (see section below for required dependencies):\n\n    $ make -C mpy-cross\n    $ cd ports/unix\n    $ make submodules\n    $ make\n\nThen to give it a try:\n\n    $ ./pycopy\n    \u003e\u003e\u003e list(5 * x + y for x in range(10) for y in [4, 2, 1])\n\nUse `CTRL-D` (i.e. EOF) to exit the shell.\nLearn about command-line options (in particular, how to increase heap size\nwhich may be needed for larger applications):\n\n    $ ./pycopy --help\n\nRun complete testsuite:\n\n    $ make test\n\nUnix version comes with a builtin package manager called `upip`, e.g.:\n\n    $ ./pycopy -m upip install pycopy-pystone\n    $ ./pycopy -m pystone\n\nBrowse available modules on [PyPI](https://pypi.org/search/?q=pycopy-).\nStandard library modules come from\n[pycopy-lib](https://github.com/pfalcon/pycopy-lib) project.\n\n`pycopy` executable built following the instructions above is a\n\"production\" executable for native Pycopy software. It's also possible\nto build `pycop-dev` executable which provides additional reflection,\ndiagnostics, and extensibility capabilities, at the expense of code\nsize and memory usage efficiency. In particular, `pycopy-dev` is more\ncompatible with software written for CPython. To build the `pycopy-dev`\nvariant, run `make dev`.\n\nExternal dependencies\n---------------------\n\nBuilding Pycopy ports may require some dependencies installed.\n\nFor Unix port, `libffi` library and `pkg-config` tool are required. On\nDebian/Ubuntu/Mint derivative Linux distros, install `build-essential`\n(includes toolchain and make), `libffi-dev`, and `pkg-config` packages.\n\nOther dependencies can be built together with Pycopy. This may\nbe required to enable extra features or capabilities, and in recent\nversions, these may be enabled by default. To build\nthese additional dependencies, first fetch git submodules for them:\n\n    $ make submodules\n\nThis will fetch all the relevant git submodules (sub repositories) that\nthe port needs.  Use the same command to get the latest versions of\nsubmodules as they are updated from time to time. After that execute:\n\n    $ make deplibs\n\nThis will build all available dependencies (regardless whether they\nare used or not). If you intend to build Pycopy with additional\noptions (like cross-compiling), the same set of options should be passed\nto `make deplibs`. To actually enable/disable use of dependencies, edit\n`ports/unix/mpconfigport.mk` file, which has inline descriptions of the options.\nFor example, to build SSL module (required for `upip` tool described above,\nand so enabled by default), `MICROPY_PY_USSL` should be set to 1.\n\nFor some ports, building required dependences is transparent, and happens\nautomatically.  But they still need to be fetched with the `make submodules`\ncommand.\n\n\u003c!--\nThe STM32 version\n-----------------\n\nThe \"stm32\" port requires an ARM compiler, arm-none-eabi-gcc, and associated\nbin-utils.  For those using Arch Linux, you need arm-none-eabi-binutils,\narm-none-eabi-gcc and arm-none-eabi-newlib packages.  Otherwise, try here:\nhttps://launchpad.net/gcc-arm-embedded\n\nTo build:\n\n    $ cd ports/stm32\n    $ make submodules\n    $ make\n\nYou then need to get your board into DFU mode.  On the pyboard, connect the\n3V3 pin to the P1/DFU pin with a wire (on PYBv1.0 they are next to each other\non the bottom left of the board, second row from the bottom).\n\nThen to flash the code via USB DFU to your device:\n\n    $ make deploy\n\nThis will use the included `tools/pydfu.py` script.  If flashing the firmware\ndoes not work it may be because you don't have the correct permissions, and\nneed to use `sudo make deploy`.\nSee the README.md file in the ports/stm32/ directory for further details.\n--\u003e\n\nContributing\n------------\n\nPycopy is an open-source project and welcomes contributions which are aligned\nwith its paradigm and work process. To be productive, please be sure to follow the\n[Contributors' Guidelines](https://github.com/pfalcon/pycopy/wiki/ContributorGuidelines)\nand the [Code Conventions](https://github.com/pfalcon/pycopy/blob/master/CODECONVENTIONS.md).\nNote that Pycopy is licenced under the MIT license, and all contributions\nshould follow this license.\n\nProject FAQ\n===========\n\nQ: How Pycopy differs from other Python implementations?\n\nA: Pycopy is intended to be a small, minimalist implementation of the\n\"core of the Python language\" (in some definition of the \"core\"). Beyond\nthat, the aim is to be extensible, to be able to support features of other\nPython implementations. Pycopy is particularly intended to write software\n(and extensions just mentioned) in Python. This may sounds as oxymoron, but\nit's a matter of fact that other implementations have too much of their\nfunctionality implemented in other languages (e.g., in C for CPython). This\nis a discouraged approach for Pycopy. Instead, for interfacing with non-Python\nlibraries, it encourages the use of FFI (Foreign Function Interface) and\nflexible import extensions.\n\nQ: How Pycopy differs from other *small* Python implementations?\n\nA: Please see previous question for general information on how Pycopy\ndiffers from other Python implementations. Regarding small Python\nimplementations specifically, a common issue with them is that they\nstructure and represent themselves as niche, special-purpose systems,\nand oftentimes implement very bare subset of Python. Pycopy isn't\njust \"Python for microcontrollers\" or \"Python to embed in other\napplication\". First and foremost, Pycopy is a general, and\ngeneral-purpose, language, suitable for developing any kind of software.\nWhich can be even used on microcontrollers and embedded in other\napplications (without growing them too much), but it's not limited\nto that in any way. Pycopy strives to cover as many systems as possible -\nfrom clouds down to tiny IoT devices. And project's attention and focus\nis also shared among them according to the functionality and value\nparticular areas may offer. For example, microcontrollers are neat cute\nthings, but you can do only so much with them, so they represent maybe\n20% of the project focus.\n\nQ: Current focus of the project?\n\nA:\n* Code optimizations.\n* Continue to develop inplace, buffer and stream operations allowing\n  to write highly memory effiicient applications.\n* Garbage collection experiments.\n* Reflection features (ultimately allowing to develop optimizing compilers,\n  etc. in Python).\n* More CPython features implemented (configurable).\n* \"Development/Testing\" version with improved program analysis features.\n* etc.\n","funding_links":[],"categories":["Forks","C","Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfalcon%2Fpycopy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpfalcon%2Fpycopy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfalcon%2Fpycopy/lists"}