refurb-json-minify
A small plugin for Refurb aimed at minifying JSON outputs.
Why is this important?
JSON is a widely used format for data exchange, whether that be APIs talking over the internet, metadata being stored in a database, or config files stored on a user's filesystem. Although CPU and harddrive space is getting cheaper and cheaper, it isn't free, and being mindful of resources can lead to faster and more efficient programs.
Supported Checks
JMIN100: Use separators
The json.dump and
json.dumps functions
allow for an optional separators field which specifies what characters to use
for colons (:) and commas (,) in the JSON output. Normally there is whitespace
after these characters, but you can change this to use a more compact format.
Here is a simple example comparing the output of json.dumps() with and without
separators specified:
import json
data = {
"hello": "world",
"numbers": [1, 2, 3, 4],
}
a = json.dumps(data)
b = json.dumps(data, separators=(",", ":"))
print(f"{len(a)=}", f"{len(b)=}")
When we run this, we get:
len(a)=43 len(b)=37
By reducing the whitespace in our JSON output we where able to shave off 6 bytes, or about 16% in this example.
JMIN101: Don't json.dump() integers
Don't call json.dump() on integers, use str() instead since they share the
same representation.
Metadata
Release files for refurb-json-minify 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 | Provenance | Actions |
|---|---|---|---|---|
| refurb-json-minify-1.0.0.tar.gz | 16.4 kB | Without provenance | Details for refurb-json-minify-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| refurb_json_minify-1.0.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for refurb_json_minify-1.0.0-py2.py3-none-any.whl |
Total release size: 33.5 kB
Release files / refurb-json-minify-1.0.0.tar.gz
| Download URL | refurb-json-minify-1.0.0.tar.gz |
|---|---|
| Size | 16.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
55831084f18cb11bc5c3eb8f7a8c6b18cf85c2c6613aabc15ae3d78516de6cb8
|
|
BLAKE2b-256 checksum How to use checksums |
39b6d3c28f58c1bebde1d8181a344cbb6725f2a5205a9695e88d11d2e45b6c14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.10.10 Linux/6.2.11-arch1-1
|
Release files / refurb_json_minify-1.0.0-py2.py3-none-any.whl
| Download URL | refurb_json_minify-1.0.0-py2.py3-none-any.whl |
|---|---|
| Size | 17.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
18a821199fe8712fc574055d232233d46565fcf8dc041803ec522e429e8f1a8c
|
|
BLAKE2b-256 checksum How to use checksums |
ef15f10b009f5c4fafb1a2b56f6c16a0ba8dda2d41d38fac50fdc6dcfa87e603
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.10.10 Linux/6.2.11-arch1-1
|
Security for refurb-json-minify 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.