This reworks some of
WebAPIResource to reduce unnecessary busywork and
reorganize some blocks of code to help with maintenance, performance,
Initial state setup for resources no longer allocates more memory for
allowed_mimetypes when there's no vendor required for resources
(though a vendor is recommended).
Dynamically-created state caches and key lookups are now accessed via a
try/except rather than a series of
in calls, which is
faster overall and especially in the common case. Some caches are now
built with reduced loops or overhead.
Object serialization now computes all request-specific code (cache
setup, expanded resources) up-front in one
if request:, in order to
make it clear what's state setup and what's payload building.
if conditions, attribute
lookups, and list allocations have been removed.
Some string building has been replaced with f-strings.
Small optimizations that add up, saving a few seconds in my typical unit
test runs for Review Board's API test suite.