app-store-server-library-python icon indicating copy to clipboard operation
app-store-server-library-python copied to clipboard

refactor library utility more pythonic

Open Reskov opened this issue 10 months ago • 2 comments

  • use .get instead of in and [] preventing extra dictionary lookup
  • use f-strings (since we support only 3.8+) reduce string concatenation overhead
  • use walrus operator (3.8+) remove extra getattr access in case raw_field found

Reskov avatar Mar 24 '25 08:03 Reskov

@Reskov Are there any performance or other reasons for performing this change besides style?

alexanderjordanbaker avatar Jul 08 '25 16:07 alexanderjordanbaker

This is more about style, rather the performance. For example, in +[] will get one extra dictionary lookup, so as general rule it is better to use get in such case. The same true about getattr, or f-string. But the impact of this is very low, so I am not sure that we will notice this in practice.

Reskov avatar Jul 08 '25 17:07 Reskov