blqs: Building Blocks for Domain Specific Languages
Blqs is a framework for building (internal) domain specific language that can be written in Python. It was inspired by TensorFlow's autograph library, and motivated by the state of the art (circa 2021) in quantum programming frameworks like Cirq and Qiskit.
In short blqs let you define domain specific languages and gives you access to use native
Python features like if, while, or for in these languages. This fills in a missing
feature for Python, which while they do have operator overloading, does not allow for
overloading these built in constructions.
Example:
import blqs
H, M, CX = blqs.Op('H'), blqs.Op('M'), blqs.Op('CX')
@blqs.build
def hello_blqs():
a = blqs.Register('a')
H(0)
M(0, 'a')
if a:
CX(0, 1)
else:
CX(1, 0)
Then, if we call this method, we will produce a blqs.Program that includes both statements,
like H(0) but also the if and else statements.
program = hello_blqs()
for s in program:
print(type(s))
> prints
> <class 'blqs.instruction.Instruction'>
> <class 'blqs.instruction.Instruction'>
> <class 'blqs.conditional.If'>
Where the last statement contains blocks that hold the CX statements.
Installation
To install blqs one can simply pip install the appropriate package
pip install blqs
See requirements.txt for the dependencies that blqs will pull in.
Documentation
A good place to get started is to read the introduction to blqs. After that, the ideas and abstractions in blqs are described in the concepts guide. To learn about support for capturing native python code, see refer to the protocols section of the docs. For a quick intro via a jupyter notebook, see hello blqs.
Metadata
Release files for blqs 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| blqs-0.1.0.tar.gz | 26.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| blqs-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 76.6 kB
Release files / blqs-0.1.0.tar.gz
| Download URL | blqs-0.1.0.tar.gz |
|---|---|
| Size | 26.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ed9692dde8730389bbf131dd602616f8d5157c2e5f42337338b5636bbf241c0
|
|
BLAKE2b-256 checksum How to use checksums |
ccb0102f664a0dea29499d25f53f7688d18ad7dc4aed3be6b15476fdfd1fc4fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Release files / blqs-0.1.0-py3-none-any.whl
| Download URL | blqs-0.1.0-py3-none-any.whl |
|---|---|
| Size | 49.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
edd48314e2788199a1bfdb05cbd94235a3194ad43d57a1d82954ea0c79992a5b
|
|
BLAKE2b-256 checksum How to use checksums |
85c5fedaaec64f33615eb0f93133058f92038c08ae738a249683380a602ae3f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|