Skip to content

Commit

Permalink
Rename performance_and_benchmark.md -> optimizations_and_benchmark.md
Browse files Browse the repository at this point in the history
  • Loading branch information
wyfo committed Dec 30, 2021
1 parent 42b03cf commit e336858
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ It requires only Python 3.6+ (and dataclasses [official backport](https://pypi.o

## Why another library?

(If you wonder how this differs from the *pydantic* library, see the [dedicated section of the documentation](https://wyfo.github.io/apischema/difference_with_pydantic/) — there are many differences.)
(If you wonder how this differs from the *pydantic* library, see the [dedicated section of the documentation](https://wyfo.github.io/apischema/dev/difference_with_pydantic/) — there are many differences.)

This library fulfills the following goals:

- stay as close as possible to the standard library (dataclasses, typing, etc.) — as a consequence we do not need plugins for editors/linters/etc.;
- be adaptable, provide tools to support any types (ORM, etc.);
- avoid dynamic things like using raw strings for attributes name — play nicely with your IDE.

No known alternative achieves all of this, and apischema is also [faster](https://wyfo.github.io/apischema/performance_and_benchmark) than all of them.
No known alternative achieves all of this, and apischema is also [faster](https://wyfo.github.io/apischema/dev/optimizations_and_benchmark) than all of them.

On top of that, because APIs are not only JSON, *apischema* is also a complete GraphQL library.

Expand Down
8 changes: 4 additions & 4 deletions docs/de_serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Only non JSON primitive classes can be allowed, because *apischema* relies on a
```

!!! note
Equivalent serialization feature is presented in [optimizations documentation](performance_and_benchmark.md#serialization-passthrough).
Equivalent serialization feature is presented in [optimizations documentation](optimizations_and_benchmark.md#serialization-passthrough).

### Strictness

Expand Down Expand Up @@ -289,11 +289,11 @@ It's true that this feature has the little cost of adding a decorator everywhere

#### Why isn't serialization type checking enabled by default?

Type checking has a runtime cost, which means poorer performance. Moreover, as explained in [performances section](performance_and_benchmark.md#serialization-passthrough), it prevents "passthrough" optimization. At last, code is supposed to be statically verified, and thus types already checked. (If some silly things are done and leads to have unsupported types passed to the JSON library, an error will be raised anyway).
Type checking has a runtime cost, which means poorer performance. Moreover, as explained in [performances section](optimizations_and_benchmark.md#serialization-passthrough), it prevents "passthrough" optimization. At last, code is supposed to be statically verified, and thus types already checked. (If some silly things are done and leads to have unsupported types passed to the JSON library, an error will be raised anyway).

Runtime type checking is more a development feature, which could for example be with `apischema.settings.serialization.check_type = __debug__`.

#### Why not use json library `default` fallback parameter for serialization?
Some *apischema* features like [conversions](conversions.md) can simply not be implemented with `default` fallback. By the way, *apischema* can perform [surprisingly better](performance_and_benchmark.md#passing-through-is-not-always-faster) than using `default`.
Some *apischema* features like [conversions](conversions.md) can simply not be implemented with `default` fallback. By the way, *apischema* can perform [surprisingly better](optimizations_and_benchmark.md#passing-through-is-not-always-faster) than using `default`.

However, `default` can be used in combination with [passthrough optimization](performance_and_benchmark.md#serialization-passthrough) when needed to improve performance.
However, `default` can be used in combination with [passthrough optimization](optimizations_and_benchmark.md#serialization-passthrough) when needed to improve performance.
2 changes: 1 addition & 1 deletion docs/difference_with_pydantic.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ As the question is often asked, it is answered in a dedicated section. Here are

### *apischema* is (a lot) faster

According to [benchmark](performance_and_benchmark.md), *apischema* is a lot faster than *pydantic*, especially for serialization. Both use Cython to optimize the code, but even without compilation (running only Python modules), *apischema* is still faster than Cythonized *pydantic*.
According to [benchmark](optimizations_and_benchmark.md), *apischema* is a lot faster than *pydantic*, especially for serialization. Both use Cython to optimize the code, but even without compilation (running only Python modules), *apischema* is still faster than Cythonized *pydantic*.

Better performance, but not at the cost of fewer functionalities; that's rather the opposite: [dynamic aliasing](json_schema.md#dynamic-aliasing-and-default-aliaser), [conversions](conversions.md), [flattened fields](data_model.md#composition-over-inheritance---composed-dataclasses-flattening), etc.

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This library fulfills the following goals:
- be adaptable, provide tools to support any types (ORM, etc.);
- avoid dynamic things like using raw strings for attributes name - play nicely with your IDE.

No known alternative achieves all of this, and apischema is also [faster](performance_and_benchmark.md#benchmark) than all of them.
No known alternative achieves all of this, and apischema is also [faster](optimizations_and_benchmark.md#benchmark) than all of them.

On top of that, because APIs are not only JSON, *apischema* is also a complete GraphQL library

Expand Down
2 changes: 1 addition & 1 deletion docs/json_schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ OpenAPI defines a [discriminator object](https://spec.openapis.org/oas/v3.1.0#di
!!! note
Using discriminator doesn't require to have a dedicated field (except for `TypedDict`)

Performance of union deserialization can be [improved](performance_and_benchmark.md#discriminator) using discriminator.
Performance of union deserialization can be [improved](optimizations_and_benchmark.md#discriminator) using discriminator.


## `readOnly` / `writeOnly`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Performance and benchmark
# Optimizations and benchmark

*apischema* is (a lot) [faster](#benchmark) than its known alternatives, thanks to advanced optimizations.

Expand Down Expand Up @@ -64,7 +64,7 @@ To take advantage of that, *apischema* provides `apischema.PassThroughOptions` c
```

!!! important
Passthrough optimization always requires `check_type` to be `False`, in parameters or settings.
Passthrough optimization is a lot diminished with `check_type=False`.

`PassThroughOptions` has the following parameters:

Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ nav:
- examples/subclass_tagged_union.md
- examples/recoverable_fields.md
- examples/inherited_deserializer.md
- performance_and_benchmark.md
- optimizations_and_benchmark.md
- difference_with_pydantic.md
- Releases: https://github.com/wyfo/apischema/releases

Expand Down

0 comments on commit e336858

Please sign in to comment.