https://github.com/cqcl/guppylang
Pythonic quantum-classical programming language
https://github.com/cqcl/guppylang
Last synced: about 1 year ago
JSON representation
Pythonic quantum-classical programming language
- Host: GitHub
- URL: https://github.com/cqcl/guppylang
- Owner: CQCL
- License: apache-2.0
- Created: 2023-04-24T09:48:07.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-29T11:36:05.000Z (over 1 year ago)
- Last Synced: 2024-10-29T11:44:32.202Z (over 1 year ago)
- Language: Python
- Homepage: https://pypi.org/project/guppylang
- Size: 2.26 MB
- Stars: 33
- Watchers: 11
- Forks: 2
- Open Issues: 100
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Guppy
[![pypi][]](https://pypi.org/project/guppylang/)
[![codecov][]](https://codecov.io/gh/CQCL/guppylang)
[![py-version][]](https://pypi.org/project/guppylang/)
[codecov]: https://img.shields.io/codecov/c/gh/CQCL/guppylang?logo=codecov
[py-version]: https://img.shields.io/pypi/pyversions/guppylang
[pypi]: https://img.shields.io/pypi/v/guppylang
Guppy is a quantum programming language that is fully embedded into Python.
It allows you to write high-level hybrid quantum programs with classical control flow and mid-circuit measurements using Pythonic syntax:
```python
from guppylang import guppy
from guppylang.std.builtins import owned
from guppylang.std.quantum import cx, h, measure, qubit, x, z
@guppy
def teleport(src: qubit @ owned, tgt: qubit) -> None:
"""Teleports the state in `src` to `tgt`."""
# Create ancilla and entangle it with src and tgt
tmp = qubit()
h(tmp)
cx(tmp, tgt)
cx(src, tmp)
# Apply classical corrections
h(src)
if measure(src):
z(tgt)
if measure(tmp):
x(tgt)
guppy.compile_module()
```
More examples and tutorials are available [here][examples].
[examples]: ./examples/
## Install
Guppy can be installed via `pip`. Requires Python >= 3.10.
```sh
pip install guppylang
```
## Development
See [DEVELOPMENT.md](https://github.com/CQCL/guppylang/blob/main/DEVELOPMENT.md) for instructions on setting up the development environment.
## License
This project is licensed under Apache License, Version 2.0 ([LICENCE][] or ).
[LICENCE]: ./LICENCE