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

Simplify utils.get_value #811

merged 4 commits into from May 15, 2018


None yet
2 participants

taion commented May 15, 2018

This is good for like a 10% speedup in the benchmark. It's not going to make a big difference, but it's a free win.

taion added some commits May 15, 2018


@taion taion force-pushed the taion:simplify-get_value branch from 8398445 to c41e301 May 15, 2018

@@ -338,7 +338,7 @@ def _get_value_for_keys(obj, keys, default):
def _get_value_for_key(obj, key, default):
return obj[key]
except (TypeError, AttributeError):

This comment has been minimized.


sloria May 15, 2018


Based on the failing Travis build, it looks like this might be necessary to support custom iterables that don't explicitly implement __getitem__ in Python 2.


Once the failing Travis build is addressed, this should be good to merge.


This comment has been minimized.


taion commented May 15, 2018

updated and fixed – i didn't realize that python2 throws AttributeError when subscripting into un-subscriptable new-style class instances rather than TypeError


sloria approved these changes May 15, 2018

@sloria sloria merged commit 6063a70 into marshmallow-code:dev May 15, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed

@taion taion deleted the taion:simplify-get_value branch May 15, 2018

@sloria sloria added this to the 3.0 milestone May 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment