Understanding the L class fastai

Hello,

I was currently going through the fastai book (very fruitful read) and came across the following syntax:

plt.plot(L(learn.recorder.values).itemgot(2));

Digging deeper I found that the L was a specific class to the fastai library. I experimented with the function a bit and saw the following changes.

I was confused as to how the structure changed in such a way. What does the L class do to the list and what do the hashtag numeric values signify?

2 Likes

I’d recommend it’s documentation in the fastcore docs here: https://fastcore.fast.ai/#L

Jeremy calls it a superpowered list :slight_smile:

4 Likes

The above link is no longer fully valid. As of December 2023, the following link should go straight to the documentation for the L class: Foundation – fastcore.

If anyone just wants a summary, here’s how the documentation for L begins:

L is a drop in replacement for a python list . Inspired by NumPy, L supports advanced indexing and has additional methods (outlined below) that provide additional functionality and encourage simple expressive code.

1 Like