question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Adjust rule] Drop SIM105 due to performance

See original GitHub issue

Desired change

  • Rule(s): SIM105
  • Adjustment: It should be dropped! Or at least highlight performance impact in the documentation!

Explanation

By conforming to this, the code will perform worse. Please check with timeit.

In [1]: %%timeit 
   ...: try: 
   ...:     a = {'a': 1} 
   ...:     a['b'] 
   ...: except KeyError: 
   ...:     pass 
   ...:                                                                                                                                                                                                    
199 ns ± 1.16 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)

In [5]: %%timeit 
   ...: with contextlib.suppress(KeyError): 
   ...:     a = {'a': 1} 
   ...:     a['b'] 
   ...:                                                                                                                                                                                                    
621 ns ± 6.38 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
atombrellacommented, Feb 9, 2022

Uh, interesting! I’ll have a look and try to fix it this week.

Do you mind sharing the project where this time actually matters?

https://github.com/django/django/pull/9038 It’s slow because of the way Python makes function calls.

1reaction
atombrellacommented, Feb 6, 2022

I found this repository because I followed your tutorial on Medium on how to write a flake8 plugin. Thanks a bunch for this! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Final rule: Pay Versus Performance - SEC.gov
Section 14(i) directs the Commission to adopt rules requiring registrants to provide disclosure of pay versus performance. The disclosure is.
Read more >
Chapter 18: Transition Rules - Louisiana State Civil Service
An employee who has a “Satisfactory” or equivalent rating effective July 1, 2012 shall become eligible for and may be granted a performance...
Read more >
How to find a bottle-neck in your rule for performance analysis
method dumps a list of nodes with associated rules. It will help you to find related rules from a problematic constraint/node.
Read more >
6 Rules of Pay for Performance for Maximum Employee ...
Rule #5: Set your goals against your baseline​​ Set goals to reduce that baseline cost. If your cost per unit is $1.00 and...
Read more >
SEC Releases Final Pay Versus Performance Rules
Set forth below is a summary of the final rules and considerations for ... A financial performance measure chosen by the company (the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found