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

models allowing immutability #44

Merged
merged 7 commits into from Jun 13, 2017
Merged

models allowing immutability #44

merged 7 commits into from Jun 13, 2017

Conversation

@samuelcolvin
Copy link
Owner

@samuelcolvin samuelcolvin commented Jun 7, 2017

ref #38

This should also allow other cleanup including m.whatever = foobar updating __values__, it's also kind of necessary for #40 and copy(),

This also gives a slight (5 - 10%) performance increase instead of 10% decrease as the previous __setattr__ approach did.

It should also decrease memory footprint as __slots__ is used and __values__ is no longer duplicated.

@samuelcolvin samuelcolvin force-pushed the immutability branch 3 times, most recently from 18af130 to 129bd27 Jun 10, 2017
@codecov
Copy link

@codecov codecov bot commented Jun 12, 2017

Codecov Report

Merging #44 into master will not change coverage.
The diff coverage is 100%.

@@          Coverage Diff          @@
##           master    #44   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          10     10           
  Lines         701    691   -10     
  Branches      156    155    -1     
=====================================
- Hits          701    691   -10

@samuelcolvin
Copy link
Owner Author

@samuelcolvin samuelcolvin commented Jun 12, 2017

ready

@samuelcolvin samuelcolvin changed the title WIP: models allowing immutability models allowing immutability Jun 12, 2017
HISTORY.rst Outdated
v0.3.0 (TBC)
............
* immutable models via ``config.allow_mutation = False``, associated cleanup and performance improvement #44
* ``setatt`` is removed as ``__setattr__`` is not intelligent #44
Copy link
Owner Author

@samuelcolvin samuelcolvin Jun 12, 2017

Typo

pydantic/main.py Outdated
self.__values__[field] = value
setattr(self, field, value)
value = input_data[field]
values[field] = value
Copy link
Owner Author

@samuelcolvin samuelcolvin Jun 12, 2017

One line

@samuelcolvin samuelcolvin merged commit 6923e5e into master Jun 13, 2017
4 checks passed
@samuelcolvin samuelcolvin deleted the immutability branch Jun 13, 2017
@samuelcolvin samuelcolvin mentioned this pull request Jun 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant