rate - Rate Helpers
- Bytes (Binary) Helpers – Methods like
b_s(),kib_s(),mib_s(),gib_s(),tib_s(),pib_s(),eib_s(),zib_s(), andyib_s()return binary byte-per-second unit calculations. - Bytes (Decimal) Helpers – Methods like
b_s(),kb_s(),mb_s(),gb_s(),tb_s(),pb_s(),eb_s(),zb_s(), andyb_s()return decimal byte-per-second unit calculations. - Bits (Binary) Helpers – Methods like
bps(),kibps(),mibps(),gibps(),tibps(),pibps(),eibps(),zibps(), andyibps()return binary bit-per-second unit calculations. - Bits (Decimal) Helpers – Methods like
bps(),kbps(),mbps(),gbps(),tbps(),pbps(),ebps(),zbps(), andybps()return decimal bit-per-second unit calculations. - Type Preservation – Preserves input types (accepts and returns
intorfloatwithout casting) to avoid arithmetic precision loss.
Signature
sizelib.rate.<helper>(value: int | float) -> int | floatBytes Helpers (Binary / Base 2)
| Helper Method | Base | Multiplier Scale | Value (e.g. for input 1) |
|---|---|---|---|
| rate.b_s(value) | BIN (2) | 1 | 1 |
| rate.kib_s(value) | BIN (2) | 1,024 | 1,024 |
| rate.mib_s(value) | BIN (2) | 1,024^2 | 1,048,576 |
| rate.gib_s(value) | BIN (2) | 1,024^3 | 1,073,741,824 |
| rate.tib_s(value) | BIN (2) | 1,024^4 | 1,099,511,627,776 |
| rate.pib_s(value) | BIN (2) | 1,024^5 | 1,125,899,906,842,624 |
| rate.eib_s(value) | BIN (2) | 1,024^6 | 1,152,921,504,606,846,976 |
| rate.zib_s(value) | BIN (2) | 1,024^7 | 1,180,591,620,717,411,303,424 |
| rate.yib_s(value) | BIN (2) | 1,024^8 | 1,208,925,819,614,629,174,706,176 |
Bytes Helpers (Decimal / Base 10)
| Helper Method | Base | Multiplier Scale | Value (e.g. for input 1) |
|---|---|---|---|
| rate.b_s(value) | DEC (10) | 1 | 1 |
| rate.kb_s(value) | DEC (10) | 1,000 | 1,000 |
| rate.mb_s(value) | DEC (10) | 1,000^2 | 1,000,000 |
| rate.gb_s(value) | DEC (10) | 1,000^3 | 1,000,000,000 |
| rate.tb_s(value) | DEC (10) | 1,000^4 | 1,000,000,000,000 |
| rate.pb_s(value) | DEC (10) | 1,000^5 | 1,000,000,000,000,000 |
| rate.eb_s(value) | DEC (10) | 1,000^6 | 1,000,000,000,000,000,000 |
| rate.zb_s(value) | DEC (10) | 1,000^7 | 1,000,000,000,000,000,000,000 |
| rate.yb_s(value) | DEC (10) | 1,000^8 | 1,000,000,000,000,000,000,000,000 |
Bits Helpers (Binary / Base 2)
| Helper Method | Base | Multiplier Scale | Value (e.g. for input 1) |
|---|---|---|---|
| rate.bps(value) | BIN (2) | 1 | 1 |
| rate.kibps(value) | BIN (2) | 1,024 | 1,024 |
| rate.mibps(value) | BIN (2) | 1,024^2 | 1,048,576 |
| rate.gibps(value) | BIN (2) | 1,024^3 | 1,073,741,824 |
| rate.tibps(value) | BIN (2) | 1,024^4 | 1,099,511,627,776 |
| rate.pibps(value) | BIN (2) | 1,024^5 | 1,125,899,906,842,624 |
| rate.eibps(value) | BIN (2) | 1,024^6 | 1,152,921,504,606,846,976 |
| rate.zibps(value) | BIN (2) | 1,024^7 | 1,180,591,620,717,411,303,424 |
| rate.yibps(value) | BIN (2) | 1,024^8 | 1,208,925,819,614,629,174,706,176 |
Bits Helpers (Decimal / Base 10)
| Helper Method | Base | Multiplier Scale | Value (e.g. for input 1) |
|---|---|---|---|
| rate.bps(value) | DEC (10) | 1 | 1 |
| rate.kbps(value) | DEC (10) | 1,000 | 1,000 |
| rate.mbps(value) | DEC (10) | 1,000^2 | 1,000,000 |
| rate.gbps(value) | DEC (10) | 1,000^3 | 1,000,000,000 |
| rate.tbps(value) | DEC (10) | 1,000^4 | 1,000,000,000,000 |
| rate.pbps(value) | DEC (10) | 1,000^5 | 1,000,000,000,000,000 |
| rate.ebps(value) | DEC (10) | 1,000^6 | 1,000,000,000,000,000,000 |
| rate.zbps(value) | DEC (10) | 1,000^7 | 1,000,000,000,000,000,000,000 |
| rate.ybps(value) | DEC (10) | 1,000^8 | 1,000,000,000,000,000,000,000,000 |
rate API - Basic Usage
from sizelib import rate
# Define bandwidth and bitrate constraints
DISK_WRITE_RATE = rate.mib_s(500) # 500 MiB/s (524,288,000 bytes/s)
DOWNLOAD_SPEED = rate.mb_s(12.5) # 12.5 MB/s (12,500,000 bytes/s)
NETWORK_BANDWIDTH = rate.mbps(100) # 100 Mbps (100,000,000 bits/s)
BUFFER_RATE = rate.mibps(50) # 50 Mibps (52,428,800 bits/s)
INTERNET_SPEED = rate.gbps(1) # 1 Gbps (1,000,000,000 bits/s)
BACKBONE_CAPACITY = rate.tbps(10) # 10 Tbps (10,000,000,000,000 bits/s)
rate API - Variables & Expressions
from sizelib import rate
# Variables and expressions are fully supported
target_speed = 50
upload_limit = rate.mbps(target_speed) # 50 Mbps (50,000,000 bits/s)
rate API - Type Preservation
from sizelib import rate
# Input types (int/float) are dynamically preserved
BANDWIDTH = rate.mbps(100)
print(BANDWIDTH) # Output: 100000000
print(type(BANDWIDTH)) # Output: <class 'int'>
THROUGHPUT = rate.mb_s(1.5)
print(THROUGHPUT) # Output: 1500000.0
print(type(THROUGHPUT)) # Output: <class 'float'>