how does pickle know which to pick?
<p>I have my pickle function working properly</p>

<pre><code>    with open(self._prepared_data_location_scalar, 'wb') as output:
        # company1 = Company('banana', 40)
        pickle.dump(X_scaler, output, pickle.HIGHEST_PROTOCOL)
        pickle.dump(Y_scaler, output, pickle.HIGHEST_PROTOCOL)


    with open(self._prepared_data_location_scalar, 'rb') as input_f:
        X_scaler = pickle.load(input_f)
        Y_scaler = pickle.load(input_f)
</code></pre>

<p>However, I am very curious how does pickle know which to load? Does it mean that everything has to be in the same sequence?</p>

<p>Yes, pickle pick objects in order of saving.</p>

<p>Intuitively, pickle append to the end when it write (dump) to a file,
and read (load) sequentially the content from a file.</p>

<p>Consequently, order is preserved, allowing you to retrieve your data in the exact order you serialize it.</p>

python pickle