<p>The <code>AsObjects.simplify</code> function is internally applied to produce the default <code>TBranch.interpretation</code> that you're using if you don't override the <code>interpretation</code> when loading a TBranch as an array. The only reason you'd pass a custom <code>interpretation</code> is if the default is wrong—it's a back-door to fixing cases in which Uproot auto-detected the <code>interpretation</code> incorrectly.</p>
<p>If the default <code>TBranch.interpreation</code> is</p>
<pre class="lang-py prettyprint-override"><code>AsObjects(AsVector(True, AsVector(False, dtype('&gt;f4')))
</code></pre>
<p>then it did <em>try</em> to simplify—i.e. replace the <code>AsObjects</code> with an <code>AsStridedObjects</code> or <code>AsJagged</code>—but couldn't. This must be a C++ <code>std::vector&lt;std::vector&lt;float&gt;&gt;</code>, which has a variable number of bytes per object, so there aren't any simplified interpretations that will work. What's &quot;simplified&quot; about <code>AsStridedObjects</code> and <code>AsJagged</code> is that they have a fixed number of bytes per object and can therefore be interpreted in bulk, without a Python for loop over all the items in the TBasket.</p>
<p>Incidentally, we studied this exact case in <a href="https://arxiv.org/abs/2102.13516" rel="nofollow noreferrer">https://arxiv.org/abs/2102.13516</a>, and the AwkwardForth solution described in that paper will be adapted into Uproot this summer. Unfortunately, that doesn't help you right now.</p>
<p>The slow-fast pattern you're seeing is because each time you ask for an entry from a different TBasket, Uproot interprets the whole TBasket. If you were running sequentially, you'd see a pause at the beginning of each TBasket. The lazy array is caching interpreted data, so when your random-access comes back to a previously read TBasket, it should be fast again: by only looking at the first few requests, you're getting an impression that each request will be slow, but that's just because early requests are more likely to hit unread TBaskets than late requests.</p>
<p>If you're only looking into this because the process as a whole is too slow (i.e. just letting it run and fill up its cache isn't good enough), then consider reading the whole TBranch into an array and randomly access the array. If your random access is in a Python loop (as opposed to Numba), then there's also nothing to be gained and some performance to be lost by calling <code>__getitem__</code> on an Awkward Array as opposed to a NumPy array, so pass <code>library=&quot;np&quot;</code>.</p>
<p>If you don't have enough memory to load the entire TBranch into an array—which could explain why you're using a lazy array—then you're in a difficult position, because the lazy array's caching would work against you: it would evict from cache the TBaskets that haven't been hit in a while, so even a long-running process would end up repeatedly reading/interpreting. This is a fundamental issue in random-access problems of data that are too large for memory: there isn't a good way to cache it because new requests keep pushing old results out of cache. (The same problem applies to disk access, web-cached data, databases, etc.)</p>
<p>Hopefully, the array fits into memory and you can random-access it in memory. Awkward Arrays have slower <code>__getitem__</code> than NumPy, but they're more compact in memory, so which one will work best for you depends on the details.</p>
<p>I hope these pointers help!</p>
Trying to improve Uproot4 Root tree file input deserialization of one branch
<p>I am using Uproot to access a Root Tree in Python and I am noticing a significant slowdown when I try to access one particular branch: wf, which contains an array of jagged arrays</p>
<p><a href="https://i.stack.imgur.com/PSBo1.png" rel="nofollow noreferrer">Root Tree Branches</a></p>
<p>I am accessing the branches by using the Lazy/Awkward method and I am using the step_size option.</p>
<pre><code>LazyFileWF = uproot.lazy('../Layers9_Xe_Phantom102_run1.root:dstree;111', filter_name= &quot;wf&quot;,step_size=100)
</code></pre>
<p>I experience a 6 to 10 second slow down when I want to access an entry in &quot;LazyFileWF&quot; but if I move on to the next consecutive entry, it only takes about 14 ms up until the end of the step_size. However my script needs to select entries randomly, not sequentially, which means every entry will take me about 8 seconds to access. I am able to access data from the other branches fairly quickly with the exception of this one and I wanted to find out why.</p>
<p>By using <code>uproot.open()</code> and then <code>.show()</code> I noticed that the interpretation of the branch was being labeled as <code>AsObjects(AsObjects(AsVector(True, AsVector(False, dtype('&gt;f4'))))</code></p>
<p>I did some digging in the Documentation and found this:</p>
<p><a href="https://i.stack.imgur.com/ryAxK.png" rel="nofollow noreferrer">Uproot AsObjects Doc</a></p>
<p>It mentions I can use <code>simplify</code> to improve the slow deserialization.</p>
<p>So here's what I would like to know, based on the Root Tree I have, can I use <code>simplify</code> to reduce the 8 second slowdown to access my branch? And if so how can implement it? Is there a better way to read this branch?</p>
<p>I tried:</p>
<pre><code>a = uproot.AsObjects.simplify(LazyFileWF.wf)
a
</code></pre>
<p>but I got an error telling me</p>
<pre><code>---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_147439/260639244.py in &lt;module&gt;
      5 LazyFileWF = uproot.lazy('../Layers9_Xe_Phantom102_run1.root:dstree;111', filter_name= &quot;wf&quot;,step_size=100)
      6 events.show(typename_width=35, interpretation_width= 60)
----&gt; 7 a = uproot.AsObjects.simplify(LazyFileWF.wf)
      8 a

~/anaconda3/envs/rapids-21.10/lib/python3.7/site-packages/uproot/interpretation/objects.py in simplify(self)
    245         ``self``.
    246         &quot;&quot;&quot;
--&gt; 247         if self._branch is not None:
    248             try:
    249                 return self._model.strided_interpretation(

~/anaconda3/envs/rapids-21.10/lib/python3.7/site-packages/awkward/highlevel.py in __getattr__(self, where)
   1129                 raise AttributeError(
   1130                     &quot;no field named {0}&quot;.format(repr(where))
-&gt; 1131                     + ak._util.exception_suffix(__file__)
   1132                 )
   1133 

AttributeError: no field named '_branch'

(https://github.com/scikit-hep/awkward-1.0/blob/1.7.0/src/awkward/highlevel.py#L1131)
</code></pre>