{"id":13501328,"url":"https://github.com/pydantic/pydantic-core","last_synced_at":"2025-05-14T22:05:40.737Z","repository":{"id":37025181,"uuid":"477896448","full_name":"pydantic/pydantic-core","owner":"pydantic","description":"Core validation logic for pydantic written in rust","archived":false,"fork":false,"pushed_at":"2025-05-09T15:14:18.000Z","size":7846,"stargazers_count":1578,"open_issues_count":89,"forks_count":281,"subscribers_count":28,"default_branch":"main","last_synced_at":"2025-05-14T22:05:12.016Z","etag":null,"topics":["json-schema","parsing","pydantic","rust","schema","validation"],"latest_commit_sha":null,"homepage":"","language":"Python","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/pydantic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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,"zenodo":null},"funding":{"github":"samuelcolvin"}},"created_at":"2022-04-04T22:36:55.000Z","updated_at":"2025-05-14T04:18:19.000Z","dependencies_parsed_at":"2023-10-16T17:03:12.801Z","dependency_job_id":"76be14db-477f-4551-8996-3a94818de0ef","html_url":"https://github.com/pydantic/pydantic-core","commit_stats":{"total_commits":1226,"total_committers":99,"mean_commits":"12.383838383838384","dds":0.597879282218597,"last_synced_commit":"184e7be2d51b1b677455597dd74507c5c53d3027"},"previous_names":[],"tags_count":135,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pydantic%2Fpydantic-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pydantic%2Fpydantic-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pydantic%2Fpydantic-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pydantic%2Fpydantic-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pydantic","download_url":"https://codeload.github.com/pydantic/pydantic-core/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254235687,"owners_count":22036962,"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":["json-schema","parsing","pydantic","rust","schema","validation"],"created_at":"2024-07-31T22:01:33.459Z","updated_at":"2025-05-14T22:05:40.633Z","avatar_url":"https://github.com/pydantic.png","language":"Python","funding_links":["https://github.com/sponsors/samuelcolvin"],"categories":["Python","Validation \u0026 Data Modeling","rust","Data Processing"],"sub_categories":[],"readme":"# pydantic-core\n\n[![CI](https://github.com/pydantic/pydantic-core/workflows/ci/badge.svg?event=push)](https://github.com/pydantic/pydantic-core/actions?query=event%3Apush+branch%3Amain+workflow%3Aci)\n[![Coverage](https://codecov.io/gh/pydantic/pydantic-core/branch/main/graph/badge.svg)](https://codecov.io/gh/pydantic/pydantic-core)\n[![pypi](https://img.shields.io/pypi/v/pydantic-core.svg)](https://pypi.python.org/pypi/pydantic-core)\n[![versions](https://img.shields.io/pypi/pyversions/pydantic-core.svg)](https://github.com/pydantic/pydantic-core)\n[![license](https://img.shields.io/github/license/pydantic/pydantic-core.svg)](https://github.com/pydantic/pydantic-core/blob/main/LICENSE)\n\nThis package provides the core functionality for [pydantic](https://docs.pydantic.dev) validation and serialization.\n\nPydantic-core is currently around 17x faster than pydantic V1.\nSee [`tests/benchmarks/`](./tests/benchmarks/) for details.\n\n## Example of direct usage\n\n_NOTE: You should not need to use pydantic-core directly; instead, use pydantic, which in turn uses pydantic-core._\n\n```py\nfrom pydantic_core import SchemaValidator, ValidationError\n\n\nv = SchemaValidator(\n    {\n        'type': 'typed-dict',\n        'fields': {\n            'name': {\n                'type': 'typed-dict-field',\n                'schema': {\n                    'type': 'str',\n                },\n            },\n            'age': {\n                'type': 'typed-dict-field',\n                'schema': {\n                    'type': 'int',\n                    'ge': 18,\n                },\n            },\n            'is_developer': {\n                'type': 'typed-dict-field',\n                'schema': {\n                    'type': 'default',\n                    'schema': {'type': 'bool'},\n                    'default': True,\n                },\n            },\n        },\n    }\n)\n\nr1 = v.validate_python({'name': 'Samuel', 'age': 35})\nassert r1 == {'name': 'Samuel', 'age': 35, 'is_developer': True}\n\n# pydantic-core can also validate JSON directly\nr2 = v.validate_json('{\"name\": \"Samuel\", \"age\": 35}')\nassert r1 == r2\n\ntry:\n    v.validate_python({'name': 'Samuel', 'age': 11})\nexcept ValidationError as e:\n    print(e)\n    \"\"\"\n    1 validation error for model\n    age\n      Input should be greater than or equal to 18\n      [type=greater_than_equal, context={ge: 18}, input_value=11, input_type=int]\n    \"\"\"\n```\n\n## Getting Started\n\nYou'll need rust stable [installed](https://rustup.rs/), or rust nightly if you want to generate accurate coverage.\n\nWith rust and python 3.9+ installed, compiling pydantic-core should be possible with roughly the following:\n\n```bash\n# clone this repo or your fork\ngit clone git@github.com:pydantic/pydantic-core.git\ncd pydantic-core\n# create a new virtual env\npython3 -m venv env\nsource env/bin/activate\n# install dependencies and install pydantic-core\nmake install\n```\n\nThat should be it, the example shown above should now run.\n\nYou might find it useful to look at [`python/pydantic_core/_pydantic_core.pyi`](./python/pydantic_core/_pydantic_core.pyi) and\n[`python/pydantic_core/core_schema.py`](./python/pydantic_core/core_schema.py) for more information on the python API,\nbeyond that, [`tests/`](./tests) provide a large number of examples of usage.\n\nIf you want to contribute to pydantic-core, you'll want to use some other make commands:\n* `make build-dev` to build the package during development\n* `make build-prod` to perform an optimised build for benchmarking\n* `make test` to run the tests\n* `make testcov` to run the tests and generate a coverage report\n* `make lint` to run the linter\n* `make format` to format python and rust code\n* `make` to run `format build-dev lint test`\n\n## Profiling\n\nIt's possible to profile the code using the [`flamegraph` utility from `flamegraph-rs`](https://github.com/flamegraph-rs/flamegraph). (Tested on Linux.) You can install this with `cargo install flamegraph`.\n\nRun `make build-profiling` to install a release build with debugging symbols included (needed for profiling).\n\nOnce that is built, you can profile pytest benchmarks with (e.g.):\n\n```bash\nflamegraph -- pytest tests/benchmarks/test_micro_benchmarks.py -k test_list_of_ints_core_py --benchmark-enable\n```\nThe `flamegraph` command will produce an interactive SVG at `flamegraph.svg`.\n\n## Releasing\n\n1. Bump package version locally. Do not just edit `Cargo.toml` on Github, you need both `Cargo.toml` and `Cargo.lock` to be updated.\n2. Make a PR for the version bump and merge it.\n3. Go to https://github.com/pydantic/pydantic-core/releases and click \"Draft a new release\"\n4. In the \"Choose a tag\" dropdown enter the new tag `v\u003cthe.new.version\u003e` and select \"Create new tag on publish\" when the option appears.\n5. Enter the release title in the form \"v\u003cthe.new.version\u003e \u003cYYYY-MM-DD\u003e\"\n6. Click Generate release notes button\n7. Click Publish release\n8. Go to https://github.com/pydantic/pydantic-core/actions and ensure that all build for release are done successfully.\n9. Go to https://pypi.org/project/pydantic-core/ and ensure that the latest release is published.\n10. Done 🎉\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpydantic%2Fpydantic-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpydantic%2Fpydantic-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpydantic%2Fpydantic-core/lists"}