Skip to content

Commit 0edfe00

Browse files
allrob23sloria
andauthored
Use set instead of list for exclude in filter_excluded_fields fucntion (#972)
* refactor: use set instead of list for exclude * Update AUTHORS and CHANGELOG --------- Co-authored-by: Steven Loria <[email protected]>
1 parent 1b4921c commit 0edfe00

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

AUTHORS.rst

+1
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,4 @@ Contributors (chronological)
8585
- `<https://github.com/kolditz-senec >`_
8686
- Theron Luhn `@luhn <https://github.com/luhn>`_
8787
- Robert Shepley `@ShepleySound <https://github.com/ShepleySound>`_
88+
- Robin `@allrob23 <https://github.com/allrob23>`_

CHANGELOG.rst

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
---------
33

4+
(unreleased)
5+
************
6+
7+
- Perf improvement to ``filter_excluded_fields`` (:issue:`972`).
8+
Thanks :user:`allrob23` for the PR.
9+
410
6.8.1 (2025-01-07)
511
******************
612

src/apispec/ext/marshmallow/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ def filter_excluded_fields(
9595
:param Meta: the schema's Meta class
9696
:param bool exclude_dump_only: whether to filter dump_only fields
9797
"""
98-
exclude = list(getattr(Meta, "exclude", []))
98+
exclude = set(getattr(Meta, "exclude", []))
9999
if exclude_dump_only:
100-
exclude.extend(getattr(Meta, "dump_only", []))
100+
exclude.update(getattr(Meta, "dump_only", []))
101101

102102
filtered_fields = {
103103
key: value

0 commit comments

Comments
 (0)