user21386: A while ago I asked a question about how to let Stockfish play 10 games with itself for a limited number of moves:
Python script to let stockfish selfplay 10 games from a given position
This question was brilliantly answered by the user Phonon.
Now I would have a followup question. Since the games are starting from the same position, I would like to avoid to clean the hash memory, as I understand Stockfish does every time it starts a new game. Ideally, even the first game should avoid the hash table clearing since I might have analyzed the position before starting the self match and I would like to keep the information saved in the hash memory.
Is there a way to do that?
Thanks in advance.

user4418: 
I would like to keep the information saved in the hash memory. Is
  there a way to do that?

Yes, there is.
Stockfish is open source. So you can examine the code, modify it, recompile and rebuild.
What you need to do is:

Find where Stockfish creates and uses the cache
Modify the code to save the cache to disk when the game finishes
Modify the code to optionally (you won't want to do it for every new game) load the cache from disk for a new game


21386: <p>A while ago I asked a question about how to let Stockfish play 10 games with itself for a limited number of moves:</p>

<p><a href="https://chess.stackexchange.com/questions/28248/python-script-to-let-stockfish-selfplay-10-games-from-a-given-position/28249#28249">Python script to let stockfish selfplay 10 games from a given position</a></p>

<p>This question was brilliantly answered by the user Phonon.</p>

<p>Now I would have a followup question. Since the games are starting from the same position, I would like to avoid to clean the hash memory, as I understand Stockfish does every time it starts a new game. Ideally, even the first game should avoid the hash table clearing since I might have analyzed the position before starting the self match and I would like to keep the information saved in the hash memory.</p>

<p>Is there a way to do that?</p>

<p>Thanks in advance.</p>
 4418: <blockquote>
  <p>I would like to keep the information saved in the hash memory. Is
  there a way to do that?</p>
</blockquote>

<p>Yes, there is.</p>

<p>Stockfish is <a href="https://github.com/official-stockfish" rel="nofollow noreferrer">open source</a>. So you can examine the code, modify it, recompile and rebuild.</p>

<p>What you need to do is:</p>

<ol>
<li>Find where Stockfish creates and uses the cache</li>
<li>Modify the code to save the cache to disk when the game finishes</li>
<li>Modify the code to optionally (you won't want to do it for every new game) load the cache from disk for a new game</li>
</ol>
