<span class="o">>>></span> <span class="k">class</span> <span class="nc">S</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="o">...</span> <span class="k">def</span> <span class="nf">__getstate__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="o">...</span> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">a</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">b</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">c</span>
<span class="o">...</span> <span class="k">def</span> <span class="nf">__setstate__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
<span class="o">...</span> <span class="bp">self</span><span class="o">.</span><span class="n">a</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">b</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">c</span> <span class="o">=</span> <span class="n">value</span><span class="p">[</span><span class="mf">0</span><span class="p">],</span> <span class="n">value</span><span class="p">[</span><span class="mf">1</span><span class="p">][:],</span> <span class="n">value</span><span class="p">[</span><span class="mf">2</span><span class="p">]</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
<span class="o">...</span>
<span class="o">>>></span> <span class="n">s1</span> <span class="o">=</span> <span class="n">S</span><span class="p">()</span>
<span class="o">>>></span> <span class="n">s1</span><span class="o">.</span><span class="n">a</span><span class="p">,</span> <span class="n">s1</span><span class="o">.</span><span class="n">b</span><span class="p">,</span> <span class="n">s1</span><span class="o">.</span><span class="n">c</span> <span class="o">=</span> <span class="p">[</span><span class="mf">1</span><span class="p">,</span><span class="mf">2</span><span class="p">],</span> <span class="p">[</span><span class="mf">3</span><span class="p">,</span><span class="mf">4</span><span class="p">],</span> <span class="p">{</span><span class="s">'spam'</span><span class="p">:</span> <span class="mf">1</span><span class="p">,</span> <span class="s">'egg'</span><span class="p">:</span> <span class="mf">2</span><span class="p">}</span>
<span class="o">>>></span> <span class="n">s2</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">s1</span><span class="p">)</span>
<span class="o">>>></span> <span class="n">s1</span><span class="o">.</span><span class="n">a</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">s1</span><span class="o">.</span><span class="n">b</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="mf">7</span>
<span class="o">>>></span> <span class="n">s1</span><span class="o">.</span><span class="n">c</span><span class="p">[</span><span class="s">'ham'</span><span class="p">]</span> <span class="o">=</span> <span class="mf">3</span>
<span class="o">>>></span> <span class="n">s2</span><span class="o">.</span><span class="n">a</span><span class="p">,</span> <span class="n">s2</span><span class="o">.</span><span class="n">b</span><span class="p">,</span> <span class="n">s2</span><span class="o">.</span><span class="n">c</span>
<span class="p">([</span><span class="o">-</span><span class="mf">7</span><span class="p">,</span> <span class="mf">2</span><span class="p">],</span> <span class="p">[</span><span class="mf">3</span><span class="p">,</span> <span class="mf">4</span><span class="p">],</span> <span class="p">{</span><span class="s">'egg'</span><span class="p">:</span> <span class="mf">2</span><span class="p">,</span> <span class="s">'spam'</span><span class="p">:</span> <span class="mf">1</span><span class="p">})</span>
<span class="o">>>></span> <span class="n">s1</span><span class="o">.</span><span class="n">a</span><span class="p">,</span> <span class="n">s1</span><span class="o">.</span><span class="n">b</span><span class="p">,</span> <span class="n">s1</span><span class="o">.</span><span class="n">c</span>
<span class="p">([</span><span class="o">-</span><span class="mf">7</span><span class="p">,</span> <span class="mf">2</span><span class="p">],</span> <span class="p">[</span><span class="o">-</span><span class="mf">7</span><span class="p">,</span> <span class="mf">4</span><span class="p">],</span> <span class="p">{</span><span class="s">'egg'</span><span class="p">:</span> <span class="mf">2</span><span class="p">,</span> <span class="s">'ham'</span><span class="p">:</span> <span class="mf">3</span><span class="p">,</span> <span class="s">'spam'</span><span class="p">:</span> <span class="mf">1</span><span class="p">})</span>