4 ms·
I wouldn’t recommend a book, instead i’d give you a couple of challenges, each of these is <1-2 hours in isolation: 1. Explain to me like i’m 5, what exac
by CraigJPerry 4y ago
I wouldn’t recommend a book, instead i’d give you a couple of challenges, each of these is <1-2 hours in isolation:
1. Explain to me like i’m 5, what exactly __slots__ is for? Write me some demo code to illustrate - the reason i’d set this challenge is because you’d come out the other side knowing how objects work and how it’s more or less dicts all the way down (to be clear, slots is an exception to the dicts all the way down view which is why i think its a good example to get stuck into)
2. Write me some demo code that explains the purpose of locals()
3. Teach me how to use dis.dis(), explain to me what each possible opcode means
4. Explain to me how to use pdb, include conveniences like breakpoint() in your explanation
5. Show me 3x working examples of calling a c function from python. Explain the different approaches you took
If you can nail these 5 questions, I’d feel pretty confident betting on you knowing enough python to be able to take on something really advanced like modifying the supported grammar of jinja for example.
- emmelaich 4y agoThese seem to be too deep in the internals for most Python programmers. OK, __slots__ and pdb, but the rest are "as needed" and don't have much to do with everyday Python programming.
- jacoberr 4y agoHonestly, I can't answer any of these fluently. What would you suggest me to do?
- TheAlchemist 4y agoThat was my reaction too ! Most of this is not useful at all for a day to day job. But then I re-read the OP question, and he asks indeed about learning Python 'in detail' - what's going on under the hood. Then I spend some time researching those questions, and it's pretty interesting !
- CraigJPerry 4y agoApologies jacoberr, i think i've misunderstood what you were asking for originally: > I feel like python is made on the simple basic structure and I don't know that ...<snip>... I feel like I really don't know the internals of python I think i took what you said a bit too literally :-) You definitely don't need this stuff to be a solid, competent Python developer. I was suggesting these topics because i feel like understanding these were what unlocked the ability for me to handle new things - things new to me, not necessarily new to python - and be able to intuit what they meant or were doing behind the scenes. This knowledge made it so that i stopped feeling like "i don't know exactly how that works" when i saw new things in Python. Don't get me wrong, it's not magic. E.g. when the walrus operator was introduced, i could guess how this was done but i didn't know just by looking at it.
- prometheon1 4y agoI think this is a challenge for you, to figure out the answer to the questions. You will need to google some things and do some experimentation with complex Python code, but when you figure out the answers you will know quite a bit about the internals of Python.