Brotlipython
Paradigm(s) | multiparadigm |
---|---|
Designed by | osmarks |
Appeared in | 2020 |
Computational class | Turing complete |
Reference implementation | see below |
Influenced by | Python |
File extension(s) | .brpy , .br , .bpy , .py.br |
Brotlipython was created to cheat in help with using Python in golfing challenges. A Brotlipython program is a Python 3 program compressed with the Brotli lossless compression algorithm.
Implementation
Here is an example interpreter, which requires python, brotli and coreutils. The Brotlipython source file is passed as the first command line argument.
#!/bin/sh Q=$(mktemp) brotli -d < $1 > $Q python3 $Q
Here is a program to compile Python to Brotlipython (first argument is Python source, second argument is Brotlipython output):
#!/bin/sh brotli -q 11 < $1 > $2
Example code
Due to character set limitations the examples will be encoded with base64. Current Brotlipython interpreters will not automatically decode this.
Hello World: DwuAcHJpbnQoIkhlbGxvLCBXb3JsZCEiKQoD
Factorizer: H5cAUIzDuLF70AaUhRjcabCtDCUN9WYpuRz2WgopOjlg/3a8fAcLOAoA0ySnHESQliXNj+euAue8n9tpZnJ6+uD8v6aDArvCAZMlJJjppbpReauF4DeqJUGaG44bM2Z/KF6JggGvCFmHkCQMCNJ4EKMwJ+UOmuKUtka
Sum two integers: HyIA+B2pU587XqeAKKwMukSBq2sGBpEkHyUAGMY1ejI=