Fastai v2 daily code walk-thrus

Thank you Jeremy, the walk-tru was great (around midnight from France but so worth it!)

The literate programming approach, with Jupyter as the editor + scripts to translate to .py and docs, is very interesting and quite different from what I know.
It’s illuminating to learn such a different way of coding.
Do you plan to describe in depth the development process and the tools you used? Will it be part of the book?


I did the exact same discovery while doing this just for the Metaclass in the initial few cells. Python programming learning at its best :slight_smile:


This seems quite important and I am not sure this behavior is widely documented. The normal flow is for __init__ to be called after __new__. __init__ gets passed as first argument whatever __new__ returns. But what happens if __new__ returns something that is not of type cls?


This is the usual scenario. If __new__ return an object of class cls, __init__ gets called.

But if it returns an object of a different type, __init__ does not get called!


So this works like this for regular classes, but does it work in the same fashion for metaclasses? :thinking:


yes, it does!

PS: As a sidenote, it seems we can conceptualize __new__ as literally being the constructor of an instance - it takes a class (and possibly other arguments) and returns an instance of that class. And __init__ is just an initializer - it gets passed the newly created instance (or whatever object of type cls __new__ returns and acts on it.


The transcript of fastai v2 walk-thru #1

1 Like

Did you find there’s somewhere in fastai v2 that we rely on that behavior? Or were you just curious? (I don’t think I was aware this happened - so if there’s somewhere in fastai that relies on this, then it might be a lucky accident!)

… seems like I am not able to convert pacific times into the correct time for Germany, so I missed watching the video live as I thought the first one would start today (Wednesday night) and not yesterday :sweat_smile: But thanks to the fast YouTube upload of the video I was able to watch it now! I took some detailed notes of the code walk-thru (hopefully I am better at taking notes than at converting timezones :smile:) and shared them here: Fastai v2 code walk-thru 1 notes

1 Like

Thanks @Honigtoast - I’ve added a link to your notes to the top post of this thread.

1 Like

I was trying to understand NewChkMeta and for that I felt I needed to take a closer look at the object model and that is how I came across this behavior. Specifically, I didn’t understand that __new__ was supposed to return an instance that would be automatically passed to __init__ and stumbled across reading about this. I haven’t seen fastai rely on this.

You got me curious @radek. Turns out it doesn’t even call __init__ of the other class!

Note that there’s nothing printed from that last cell.


I use and find it helpful this simple service –

Yep, thanks, that’s the tool I used too :thinking: The top post from Jeremy says it was created on “Sep 3”, so that was Tuesday and therefore I thought that

at 2.30pm pacific starting tomorrow.

will mean Wednesday 2.30pm which would be Wednesday 11:30pm here in Germany… my guess is that the time that is displayed in the forums is my local time and that would mean, Jeremy wrote the post on Monday evening and that was the thing I missed while converting the timezones :sweat_smile:


If it’s useful to anyone, I made a (completely unmaintained and probably very unreliable) Dockerfile based on nvidia-docker to play around with fastai_dev

I pushed it to
in case anyone wants to use it. Notice that the image is quite huge (almost 10GB)

EDIT: it can be pulled with docker pull mikonapoli/fastai-dev but you will have to rebuild the image if you want to pull the latest version of the repo. (or just connect to the running container and git pull)

Any idea how long is the rough estimate for v2 release officially?


1 Like

I’m thinking for today’s walk-thru I’ll switch to just YouTube Live and have questions in a forum thread - i.e. just like we do for normal fastai Live lessons. Or maybe I’ll use youtube live chat for questions, so that they can be replayed in real-time. Either way, there will be a link in the top post closer to the time.


It would be nice if questions (and answers) were documented in forums for ppl that can’t attend live sessions.


I’ve added the next walk-thru live link to the top post. I’ll be using Youtube Live, including the youtube chat for questions/discussion. Here’s the link:


Love the new L() instead of list() functionality! This could even be useful outside of the fastai lib! But one question: You mention wanting to use that everywhere instead of list. Will that have Performance implications, has anybody tested that? (list being part of the languange and therefore in C vs. L having a lot more functionality but being Python)

1 Like

Have a look at the implementation of L - you’ll see it’s all being passed down to fast python functions. So performance should be identical.


I wonder how did you get this?

1 Like