Why use contextlib.suppress as opposed to try/except with pass? : <p>Why would one use <a href="https://docs.python.org/3/library/contextlib.html#contextlib.suppress"><code>contextlib.suppress</code></a> to suppress an exception, instead of <code>try</code>/<code>except</code> with a <code>pass</code>?</p>

<p>There is no difference in the amount of characters between these two methods (if anything, <code>suppress</code> has more characters), and even though code is often counted in LOC instead of characters, <code>suppress</code> also seems to be much slower than <code>try</code>/<code>except</code> in both cases, when an error is raised and when it's not:</p>

<pre><code>Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
&gt;&gt;&gt; from timeit import timeit
&gt;&gt;&gt; # With an error
&gt;&gt;&gt; timeit("""with suppress(ValueError):
    x = int('a')""", setup="from contextlib import suppress")
1.9571568971892543
&gt;&gt;&gt; timeit("""try:
    x = int('a')
except ValueError:
    pass""")
1.0758466499161656
&gt;&gt;&gt; # With no error
&gt;&gt;&gt; timeit("""with suppress(ValueError):
    x = int(3)""", setup="from contextlib import suppress")
0.7513525708063895
&gt;&gt;&gt; timeit("""try:
    x = int(3)
except ValueError:
    pass""")
0.10141028937128027
&gt;&gt;&gt; 
</code></pre>
