Pouty: a very silly library bringing weird C++ features to Python since 2022
Do you like Python? Wanna use std::cout in it? No? I didn't ask!
pouty is a Python package that will make you pout with it's ability to use C++ style IO in Python.
FAQ:
- Is it fast? No.
- Does C++ I/O even make sense in this context? That's for you to judge.
- Is it faster than Python's print()? While it may occasionally avoid a string creation or contcatenation, it does so through multiple operator overloads and several function calls + type checks. Therefore, no.
- Why is C++'s iostream fast? C++ is a compiled language with static typing and function call inlining.
- Why make this? Because I can.
Example code (examples/test.py):
from pouty.iostream import *;
import random;
std.cout << "Hello, world!" << std.endl
class CustomOutput: #custom operator<< and operator>> overload supported
is_pouty_stream = True
def __init__(self) -> None:
self.x = ref(0)
pass
def __lshift__(self, other: any) -> None:
other << self.x[...]
def __rshift__(self, other: any) -> None:
other >> self.x
# Python [unfortunately, perhaps fortunately!] does not have implicit reference parameters.
x = ref(0)
std.cin >> x
std.cout << x << std.endl # uses the __str__ method of ref
std.cout << x[...] << std.endl # dereferences the ref and prints the int
x = CustomOutput()
std.cin >> x
std.cout << x << std.endl
x = random.random() #precision is supported too!
std.cout << x << std.endl
std.cout << std.precision(3)
std.cout << x << std.endl
using_namespace(globals(), "std")
cout << "Hello, world!" << endl # bringing namespace pollution into Python since 2022 :)
from pouty.stdlib.h import *;
printf("%s", "Hello, world!")
printf("%d", 123) #note that precision is not supported yet here (feel free to contrubute it)
puts("Hello, world!")
Installation
pip install pouty
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss the change.
Metadata
Release files for pouty 1.0.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 | |
|---|---|---|---|
| pouty-1.0.0.tar.gz | 4.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pouty-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.6 kB
Release files / pouty-1.0.0.tar.gz
| Download URL | pouty-1.0.0.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
88fb779350a3ab06cb77a4317d484912212f49093597b7698726e89f1c82c9a7
|
|
BLAKE2b-256 checksum How to use checksums |
7e8cdf0562a635c94714cd1c033b39a089de2de146d10ed6e93dbad651372898
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.6
|
Release files / pouty-1.0.0-py3-none-any.whl
| Download URL | pouty-1.0.0-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0d34c0809c5ab9458e5ebb30af050177fe6b26ec4837a110cda072de35d2b902
|
|
BLAKE2b-256 checksum How to use checksums |
380d7c5f8e316c30e34d3e02a7c1cf0ed68f651175fe0948736a1eb798d5606f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.6
|