{"id":16519222,"url":"https://github.com/davidhewitt/pythonize","last_synced_at":"2025-05-14T20:10:00.045Z","repository":{"id":42433084,"uuid":"285867319","full_name":"davidhewitt/pythonize","owner":"davidhewitt","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-25T11:00:41.000Z","size":144,"stargazers_count":232,"open_issues_count":9,"forks_count":33,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-25T12:19:26.728Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidhewitt.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"davidhewitt"}},"created_at":"2020-08-07T15:53:37.000Z","updated_at":"2025-04-25T11:00:45.000Z","dependencies_parsed_at":"2023-02-12T15:00:53.183Z","dependency_job_id":"94409cf7-f052-4dfa-adab-a684dc499398","html_url":"https://github.com/davidhewitt/pythonize","commit_stats":{"total_commits":90,"total_committers":19,"mean_commits":"4.7368421052631575","dds":0.7222222222222222,"last_synced_commit":"8f76041f7269518d30ece732bc4e4b2df6499059"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidhewitt%2Fpythonize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidhewitt%2Fpythonize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidhewitt%2Fpythonize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidhewitt%2Fpythonize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidhewitt","download_url":"https://codeload.github.com/davidhewitt/pythonize/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254219374,"owners_count":22034397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T16:45:55.201Z","updated_at":"2025-05-14T20:10:00.019Z","avatar_url":"https://github.com/davidhewitt.png","language":"Rust","readme":"# Pythonize\n\nThis is an experimental serializer for Rust's serde ecosystem, which can convert Rust objects to Python values and back.\n\nAt the moment the Python structures it produces should be _very_ similar to those which are produced by `serde_json`; i.e. calling Python's `json.loads()` on a value encoded by `serde_json` should produce an identical structure to\nthat which is produced directly by `pythonize`.\n\n## Usage\n\nThis crate converts Rust types which implement the [Serde] serialization\ntraits into Python objects using the [PyO3] library.\n\nPythonize has two main public APIs: `pythonize` and `depythonize`.\n\n\u003c/div\u003e\n\n[Serde]: https://github.com/serde-rs/serde\n[PyO3]: https://github.com/PyO3/pyo3\n\n# Examples\n\n```rust\nuse serde::{Serialize, Deserialize};\nuse pyo3::prelude::*;\nuse pythonize::{depythonize, pythonize};\n\n#[derive(Debug, Serialize, Deserialize, PartialEq)]\nstruct Sample {\n    foo: String,\n    bar: Option\u003cusize\u003e\n}\n\nlet sample = Sample {\n    foo: \"Foo\".to_string(),\n    bar: None\n};\n\nPython::with_gil(|py| {\n    // Rust -\u003e Python\n    let obj =  pythonize(py, \u0026sample).unwrap();\n\n    assert_eq!(\"{'foo': 'Foo', 'bar': None}\", \u0026format!(\"{}\", obj.repr().unwrap()));\n\n    // Python -\u003e Rust\n    let new_sample: Sample = depythonize(\u0026obj).unwrap();\n\n    assert_eq!(new_sample, sample);\n})\n```\n","funding_links":["https://github.com/sponsors/davidhewitt"],"categories":["Utilities"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidhewitt%2Fpythonize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidhewitt%2Fpythonize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidhewitt%2Fpythonize/lists"}