Title: Add support for serde-json arbitrary_precision · Issue #101 · davidhewitt/pythonize · GitHub
Open Graph Title: Add support for serde-json arbitrary_precision · Issue #101 · davidhewitt/pythonize
X Title: Add support for serde-json arbitrary_precision · Issue #101 · davidhewitt/pythonize
Description: When the arbitrary_precision feature is enabled, pythonize serializes all numbers like {'$serde_json::private::Number': '2'} instead of 2. To reproduce Cargo.toml [package] name = "pythonize_bug" version = "0.1.0" edition = "2024" [lib] ...
Open Graph Description: When the arbitrary_precision feature is enabled, pythonize serializes all numbers like {'$serde_json::private::Number': '2'} instead of 2. To reproduce Cargo.toml [package] name = "pythonize_bug" v...
X Description: When the arbitrary_precision feature is enabled, pythonize serializes all numbers like {'$serde_json::private::Number': '2'} instead of 2. To reproduce Cargo.toml [package] name = &...
Opengraph URL: https://github.com/davidhewitt/pythonize/issues/101
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add support for serde-json arbitrary_precision","articleBody":"When the `arbitrary_precision` feature is enabled, pythonize serializes all numbers like `{'$serde_json::private::Number': '2'}` instead of `2`.\n\n## To reproduce\n\n### Cargo.toml\n\n```toml\n[package]\nname = \"pythonize_bug\"\nversion = \"0.1.0\"\nedition = \"2024\"\n\n[lib]\ncrate-type = [\"cdylib\"]\n\n[dependencies]\npyo3 = { version = \"0.27\", features = [\"extension-module\"] }\npythonize = \"0.27\"\nserde_json = { version = \"1.0\", features = [\"arbitrary_precision\"] }\n```\n\n### pyproject.toml\n\n```toml\n[build-system]\nrequires = [\"maturin\u003e=1.4,\u003c2.0\"]\nbuild-backend = \"maturin\"\n\n[project]\nname = \"pythonize_bug\"\nversion = \"0.1.0\"\n\n[tool.maturin]\nmodule-name = \"pythonize_bug\"\n```\n\n### src/lib.rs\n\n```rust\nuse pyo3::prelude::*;\nuse pythonize::{depythonize, pythonize};\nuse serde_json::Value;\n\n#[pyfunction]\nfn test_roundtrip\u003c'py\u003e(py: Python\u003c'py\u003e, obj: Bound\u003c'py, PyAny\u003e) -\u003e PyResult\u003cBound\u003c'py, PyAny\u003e\u003e {\n let value: Value = depythonize(\u0026obj)?;\n Ok(pythonize(py, \u0026value)?)\n}\n\n#[pymodule]\nfn pythonize_bug(m: \u0026Bound\u003c'_, PyModule\u003e) -\u003e PyResult\u003c()\u003e {\n m.add_function(wrap_pyfunction!(test_roundtrip, m)?)?;\n Ok(())\n}\n```\n\n### Install\n\n```bash\nuv venv\nuv pip install maturin\nuv run maturin develop\n```\n\n### Run\n\n```shell-session\n$ uv run python -c 'from pythonize_bug import test_roundtrip; print(test_roundtrip(18446744073709551615))'\n{'$serde_json::private::Number': '18446744073709551615'}\n```\n\nIf `, features = [\"arbitrary_precision\"]` is removed from Cargo.toml and `uv run maturin develop` is run:\n\n```shell-session\n$ uv run python -c 'from pythonize_bug import test_roundtrip; print(test_roundtrip(18446744073709551615))'\nTraceback (most recent call last):\n File \"\u003cstring\u003e\", line 1, in \u003cmodule\u003e\nException: JSON number out of range\n```\n","author":{"url":"https://github.com/jpmckinney","@type":"Person","name":"jpmckinney"},"datePublished":"2025-11-26T05:54:19.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/101/pythonize/issues/101"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:79b29f36-b732-6298-7857-b61e59c5b025 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A92E:1094D4:A4206C:DD1A76:698F714B |
| html-safe-nonce | b3b43f833776ecff2ecf0e8f673f6ef35ca32494471ea828574878744f21be34 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTJFOjEwOTRENDpBNDIwNkM6REQxQTc2OjY5OEY3MTRCIiwidmlzaXRvcl9pZCI6IjMxOTYxMTcwNjkxODg3ODg1NTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6739a52788d8ed5ab6060f74e74e50288bc975e5749ee6555bce59598d9eda1a |
| hovercard-subject-tag | issue:3665930194 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/davidhewitt/pythonize/101/issue_layout |
| twitter:image | https://opengraph.githubassets.com/966f5ce11fac69d007ab27729fb327e923c195eaf4e6ae9cf176ddb2cdc54908/davidhewitt/pythonize/issues/101 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/966f5ce11fac69d007ab27729fb327e923c195eaf4e6ae9cf176ddb2cdc54908/davidhewitt/pythonize/issues/101 |
| og:image:alt | When the arbitrary_precision feature is enabled, pythonize serializes all numbers like {'$serde_json::private::Number': '2'} instead of 2. To reproduce Cargo.toml [package] name = "pythonize_bug" v... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jpmckinney |
| hostname | github.com |
| expected-hostname | github.com |
| None | a40913be56b49e6322246e4bcd65ab6ec4b458c6dca6b691d30419da1e5ee35e |
| turbo-cache-control | no-preview |
| go-import | github.com/davidhewitt/pythonize git https://github.com/davidhewitt/pythonize.git |
| octolytics-dimension-user_id | 1939362 |
| octolytics-dimension-user_login | davidhewitt |
| octolytics-dimension-repository_id | 285867319 |
| octolytics-dimension-repository_nwo | davidhewitt/pythonize |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 285867319 |
| octolytics-dimension-repository_network_root_nwo | davidhewitt/pythonize |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ca6051e0ba2303370981e3d01e2bc1044eb3b429 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width