Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #33406 -- Avoided creation of MaxLengthValidator(None) when resolving Value.output_field for strings. #15277

Merged
merged 2 commits into from Jan 4, 2022

Conversation

kezabelle
Copy link
Contributor

Ticket is 33406 - 'Micro-optimisation for Value._resolve_output_field (by modifying CharField.__init__)'

This brings the behaviour in line with Field subclasses which append to the validators within __init__, like BinaryField, and prevents the creation of a validator which incorrectly throws a TypeError, if it were used.

Locally this benchmarks as saving roughly 2µs per invocation; see ticket for full examples.

Lets see if the tests pass, given I've had to pull and rebase and haven't tested beyond the default sqlite runtests.

@felixxm felixxm self-assigned this Jan 3, 2022
@felixxm felixxm changed the title Fixed #33406 -- Avoided creating a MaxLengthValidator when resolving the output field of Value Fixed #33406 -- Avoided creation of MaxLengthValidator(None) when resolving Value.output_field for strings. Jan 4, 2022
@felixxm
Copy link
Member

felixxm commented Jan 4, 2022

@kezabelle Thanks 👍

…olving Value.output_field for strings.

This brings the behaviour in line with Field subclasses which append to
the validators within __init__(), like BinaryField, and prevents the
creation of a validator which incorrectly throws a TypeError, if it
were used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants