https://github.com/pomponchik/supertime
A living example of context-aware functions
https://github.com/pomponchik/supertime
Last synced: 4 months ago
JSON representation
A living example of context-aware functions
- Host: GitHub
- URL: https://github.com/pomponchik/supertime
- Owner: pomponchik
- License: mit
- Created: 2025-05-14T10:36:37.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-14T14:02:24.000Z (about 1 year ago)
- Last Synced: 2025-06-09T21:07:18.498Z (about 1 year ago)
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# supertime: a living example of the superfunctions
[](https://pepy.tech/project/supertime)
[](https://pepy.tech/project/supertime)
[](https://coveralls.io/github/pomponchik/supertime?branch=main)
[](https://github.com/boyter/scc/)
[](https://hitsofcode.com/github/pomponchik/supertime/view?branch=main)
[](https://github.com/pomponchik/supertime/actions/workflows/tests_and_coverage.yml)
[](https://pypi.python.org/pypi/supertime)
[](https://badge.fury.io/py/supertime)
[](http://mypy-lang.org/)
[](https://github.com/astral-sh/ruff)
The [transfunctions](https://github.com/pomponchik/transfunctions) library introduces a new type of function: `superfunction`. They can behave both as regular and asynchronous functions, depending on the context, that is, on how the user uses them. This micro-library demonstrates the smallest example of this concept that I could come up with.
Install it:
```bash
pip install supertime
```
And try:
```python
from asyncio import run
from supertime import supersleep
supersleep(5) # sleeps 5 sec.
run(supersleep(5)) # sleeps 5 sec., but ASYNCHRONOUSLY.
```
As you can see, the superfunction can automatically adjust to how the calling code uses it.