title: Python: Checking if an object is atomically pickleable
body: <p>What's an accurate way of checking whether an object can be atomically pickled? When I say "atomically pickled", I mean without considering other objects it may refer to. For example, this list:</p>
  
  <pre><code>l = [threading.Lock()]
  </code></pre>
  
  <p>is not a a pickleable object, because it refers to a <code>Lock</code> which is not pickleable. But atomically, this list itself is pickleable.</p>
  
  <p>So how do you check whether an object is atomically pickleable? (I'm guessing the check should be done on the class, but I'm not sure.)</p>
  
  <p>I want it to behave like this:</p>
  
  <pre><code>&gt;&gt;&gt; is_atomically_pickleable(3)
  True
  &gt;&gt;&gt; is_atomically_pickleable(3.1)
  True
  &gt;&gt;&gt; is_atomically_pickleable([1, 2, 3])
  True
  &gt;&gt;&gt; is_atomically_pickleable(threading.Lock())
  False
  &gt;&gt;&gt; is_atomically_pickleable(open('whatever', 'r'))
  False
  </code></pre>
  
  <p>Etc.</p>