Skip to content

Commit d45cc57

Browse files
committed
update readme
1 parent 6b54b14 commit d45cc57

File tree

1 file changed

+7
-50
lines changed

1 file changed

+7
-50
lines changed

README.md

+7-50
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,14 @@
66
[![versions](https://img.shields.io/pypi/pyversions/pydantic-core.svg)](https://github.com/pydantic/pydantic-core)
77
[![license](https://img.shields.io/github/license/pydantic/pydantic-core.svg)](https://github.com/pydantic/pydantic-core/blob/main/LICENSE)
88

9-
This package provides the core functionality for pydantic.
9+
This package provides the core functionality for [pydantic](https://docs.pydantic.dev) validation and serialization.
1010

11-
The package is currently a work in progress and subject to significant change.
12-
13-
There is, as yet, no integration with pydantic, so schemas can only be defined via dictionaries.
14-
15-
The plan is for pydantic to adopt `pydantic-core` in v2 and to generate the schema definition from type hints in
16-
pydantic, then create a `SchemaValidator` upon model creation.
17-
18-
`pydantic-core` will be a separate package, required by `pydantic`.
11+
Pydantic-core is currently around 17x faster than pydantic V1.
12+
See [`tests/benchmarks/`](./tests/benchmarks/) for details.
1913

20-
The public interface to pydantic shouldn't change too much as a result of this switch
21-
(though I intend to clean up quite a lot in the public API in v2 as well).
14+
## Example of direct usage
2215

23-
Example of usage:
16+
_NOTE: You should not need to use pydantic-core directly, instead use pydantic which which in turn uses pydantic-core._
2417

2518
```py
2619
from pydantic_core import SchemaValidator, ValidationError
@@ -74,21 +67,8 @@ except ValidationError as e:
7467
"""
7568
```
7669

77-
Pydantic-core is currently around 17x faster than pydantic standard.
78-
See [`tests/benchmarks/`](./tests/benchmarks/) for details.
79-
80-
This relative performance will be less impressive for small models but could be significantly move impressive
81-
for deeply nested models.
82-
83-
The improvement will decrease slightly when we have to create a class instance after validation,
84-
but shouldn't change more.
85-
86-
The aim is to remain 10x faster than current pydantic for common use cases.
87-
8870
## Getting Started
8971

90-
While pydantic-core is not yet released and not designed for direct use, you can still try it.
91-
9272
You'll need rust stable [installed](https://rustup.rs/), or rust nightly if you want to generate accurate coverage.
9373

9474
With rust and python 3.7+ installed, compiling pydantic-core should be possible with roughly the following:
@@ -106,8 +86,8 @@ make install
10686

10787
That should be it, the example shown above should now run.
10888

109-
You might find it useful to look at [`pydantic_core/_pydantic_core.pyi`](./python/pydantic_core/_pydantic_core.pyi) and
110-
[`pydantic_core/core_schema.py`](./python/pydantic_core/core_schema.py) for more information on the python API,
89+
You might find it useful to look at [`python/pydantic_core/_pydantic_core.pyi`](./python/pydantic_core/_pydantic_core.pyi) and
90+
[`python/pydantic_core/core_schema.py`](./python/pydantic_core/core_schema.py) for more information on the python API,
11191
beyond that, [`tests/`](./tests) provide a large number of examples of usage.
11292

11393
If you want to contribute to pydantic-core, you'll want to use some other make commands:
@@ -118,26 +98,3 @@ If you want to contribute to pydantic-core, you'll want to use some other make c
11898
* `make lint` to run the linter
11999
* `make format` to format python and rust code
120100
* `make` to run `format build-dev lint test`
121-
122-
## Why not JSONSchema?
123-
124-
Looking at the above schema passed to `SchemaValidator` it would seem reasonable to ask "why not use JSONSchema?".
125-
126-
And if we could use JSONSchema, why not use an existing rust library to do validation?
127-
128-
In fact, in the very early commits to pydantic-core, I did try to use JSONSchema,
129-
however I quickly realized it wouldn't work.
130-
131-
JSONSchema does not match the schema for pydantic that closely:
132-
* there are lots of extra checks which pydantic wants to do and aren't covered by JSONSchema
133-
* there are configurations which are possible in JSONSchema but are hard or impossible to imagine in pydantic
134-
* pydantic has the concept of parsing or coercion at it's core, JSONSchema doesn't -
135-
it assumes you either accept or reject the input, never change it
136-
* There are whole classes of problem pydantic has to deal with (like python class instance validation) which JSONSchema
137-
has no idea about since it's dedicated to JSON
138-
139-
Even if we could use JSONSchema, it wouldn't help much since rust JSONSchema validators expect to know the
140-
schema at compile time, pydantic-core has no knowledge of the schema until `SchemaValidator` is initialised.
141-
142-
Still, it wouldn't be that hard to implement a conversion layer (either in python or rust) to convert JSONSchema
143-
to "pydantic schema" and thereby achieve partial JSONSchema validation.

0 commit comments

Comments
 (0)