title: Which way is efficient: build a list and then convert it to numpy array or from the begining use numpy array?
body: <ul>
  <li>Operating System: Windows, 64</li>
  <li>Python version: 3.7.11</li>
  <li>PyTorch version: 1.10.0 - cpu only</li>
  <li>IDE: Jupyter Notebook (with conda env)</li>
  </ul>
  <p>I have a class with <code>x_indices</code> and <code>x_tokens</code> properties.</p>
  <p>The class is not necessary, but if you think it helps you can download it <a href="https://icedrive.net/0/0fccRIBCFM" rel="nofollow noreferrer">here</a>.</p>
  <p>These two properties are empty lists at first and get elements (list elements) over time.</p>
  <p><code>x_indices</code> get list of numbers</p>
  <p><code>x_tokens</code> get list of strings</p>
  <pre><code># x_tokens looks something like:
  [[&quot;first&quot;, &quot;second&quot;], 
   [&quot;third&quot;, &quot;forth&quot;], 
   ..., 
   [&quot;n-1th&quot;, &quot;nth&quot;]
  ]
  </code></pre>
  <p>At the end, each of two lists have 9019 rows and 18427 columns.</p>
  <p>I want to use <code>x_tokens</code> as input to a convolutional neural network in PyTorch.</p>
  <p>Question:</p>
  <p>Given that <code>x_tokens</code> and <code>x_indices</code> will have large shape, which below ways in defining them is more efficient and why?</p>
  <ul>
  <li>first, define it as <strong>list</strong> and then convert it to <strong>nparray</strong> and then convert it to <strong>PyTorch tensor</strong> or</li>
  <li>first, define it as <strong>nparray</strong> and then convert it to <strong>PyTorch tensor</strong> or</li>
  <li>from the first, define it as <strong>PyTorch tensor</strong> tensor</li>
  </ul>