How variables work in Python | Explained with Animations [See description/first comment]

  Рет қаралды 42,989

Sreekanth

Sreekanth

Күн бұрын

The same video is re-uploaded with better audio and minor corrections: • How variables works in...
This video tries to explain how variables or name bindings work in Python and their internal representations like PyObject and PyVarObjects, using animations.
Intermediate level concepts like reference counting, garbage collection, how lists work internally, why python is a dynamically typed language, interning, None objects, equality operators like '==' and 'is', how 'del' works, how variables are passed into functions(pass by reference), issues with default mutable parameters, operator overloading and behaviour of augmented arithmetic assignment operators, the behaviour of mutable element in the tuple are also explained.
It also shows how mutable and immutable data types behave differently in some scenarios. This knowledge should be useful for people coming from other languages like C, Rust, or Golang and may enable them to write better Python code.
References
------------------
comments in CPython source code: github.com/python/cpython/blo...
Chapters
---------------
0:00 How variables works in C
0:49 How variables works in Python
3:12 How lists are represented internally
5:37 Interning
7:12 Equality operators
8:13 Pass by reference to functions
9:18 Mutable default parameters
11:24 Augmented arithmetic assignment operators
13:12 Mutable elements in Tuple

Пікірлер: 98
@sajjadhossan7972
@sajjadhossan7972 2 жыл бұрын
You really have an unique way to teach with deep understanding about programming. Please continue with your work. We wants to learn more about python from you.
@maksymilianbiruk6877
@maksymilianbiruk6877 2 жыл бұрын
I have never seen such a better explanation than this before! Thank you so much for this video.
@sreekanthpr
@sreekanthpr 10 ай бұрын
*The same video is re-uploaded with better audio and minor corrections:* kzbin.info/www/bejne/eKuWmqVjq7Ckoc0
@me-jn1zl
@me-jn1zl Жыл бұрын
I have seen 4 of your videos in a row... THEY ARE EXCELENT!!! you are a great teacher... Please continue uploading such quality videos 🙏 HAVENT SEEN ANYTHING SO WELL EXPLAINED AS YOUR VIDEOS
@maxciencomp
@maxciencomp 2 жыл бұрын
Incredible material, very clear! Thank you so much for this!
@neoruss3553
@neoruss3553 Жыл бұрын
Watched almost all videos on advance topics of python. Even though i never used python i can say these advanced topics are same or very similar for 90% of other programming languages, so learning it once means you can use it in any other language.
@DjWhitefoxMadrid
@DjWhitefoxMadrid 2 жыл бұрын
Must watch tutorial. Please keep it up with more like this. Thank you!
@sidlas420
@sidlas420 3 жыл бұрын
Very good visuals. However a small suggestion that it would be even more impactful if you explained it rather than a robotic voice reading through the statements.
@sreekanthpr
@sreekanthpr 3 жыл бұрын
Thank you. I used text to speech conversion because of two main reasons: first is that I don't have a good enough setup for recording audio and this is much easier, second I'm not a native english speaker, so some people may have difficulty with the accent.
@sidlas420
@sidlas420 3 жыл бұрын
@@sreekanthpr - You are a very thoughtful person. Thank you for the extra effort you have put in
@rainforest3233
@rainforest3233 2 жыл бұрын
@@sreekanthpr I like your content! Really helpful!! Maybe you can consider hiring someone or using a more natural voice.
@xiam19
@xiam19 Жыл бұрын
Its perfect you just need to adjust the speed to 1,2x😅
@ahmedouerfelli4709
@ahmedouerfelli4709 Жыл бұрын
This channel is underrated.
@kraken3950
@kraken3950 4 ай бұрын
Thanks. I have been coding in Python for years and only learn this piece of fundamental knowledge from your video.
@abhisekrout976
@abhisekrout976 2 жыл бұрын
Very well explained. Your videos deserve more views.
@arpankarmakar15
@arpankarmakar15 Жыл бұрын
You really understand python deeply! Great
@iliya-malecki
@iliya-malecki Жыл бұрын
Outstanding video, its like an ascii table that some nerds print and hang in their bedrooms - the quintessential information. I will save this video on a flash drive and will put it on my bedside table
@AnantaAkash.Podder
@AnantaAkash.Podder 8 күн бұрын
This by far the Best... In terms of explaining how Python Variables are Stored
@jannickharambe8550
@jannickharambe8550 8 ай бұрын
holy shit this is really really good ive googled for quite a while now and couldnt find any good explanations thanks so much
@AnantaAkash.Podder
@AnantaAkash.Podder 8 күн бұрын
You really do have an Unique way of Explaining things to others
@rvoros
@rvoros Жыл бұрын
absolutely spot on explanation with excellent examples
@RahulSharma-lw2ss
@RahulSharma-lw2ss Жыл бұрын
Very exceptionally explained. Thankyou
@clipdat345
@clipdat345 Жыл бұрын
impressive explanation, thank you!
@sanv9853
@sanv9853 10 ай бұрын
thanks for putting together this explanation, after going through countless beginner tutorials i hit gold
@JosueZelayah
@JosueZelayah Жыл бұрын
Dude you nailed it! Excellent work!
@kakarot1223
@kakarot1223 3 жыл бұрын
great video mate, never knew about all this despite using python for some while
@13MrMusic
@13MrMusic Жыл бұрын
Extremely enlightening! Excelent job, extremely well done! It was very helpful
@adityachoudhari1158
@adityachoudhari1158 Жыл бұрын
Thank-you! It's what i was looking for.
@user-rh8zz4jh2l
@user-rh8zz4jh2l 3 жыл бұрын
It's a usefull lesson) I am the beginner in Python and as for me, this lesson was very interesting) Thank you, my friend for your work)
@halciik
@halciik 7 ай бұрын
This is what i wanted to know! Thanks!
@didimomani1565
@didimomani1565 6 ай бұрын
u r great , I really didnt understand from anyone on youtube just you
@cb9493
@cb9493 2 ай бұрын
Best explanation ever, thanks a million!!!!
@arlaxia
@arlaxia 2 жыл бұрын
Really great animations and explanations. It was really informative and visual.
@winterwilderness5073
@winterwilderness5073 9 ай бұрын
Very thorough explanation and vivid visualization. Thank you so much for your efforts in producing such extraordinary contents!
@priyankagupta119
@priyankagupta119 2 жыл бұрын
Your videos are very helpful and give me deep understanding of the concepts in Python. Request you to please make a full playlist of Python-Basic, Medium, Advance concepts. Thank you so much !!
@sudarshanvkudli9250
@sudarshanvkudli9250 3 ай бұрын
This 15 minutes taught me more than what I learnt in a semester
@jakub1908
@jakub1908 2 жыл бұрын
Keep going, great job!
@sureshonteru4609
@sureshonteru4609 7 ай бұрын
This video helped me a lot , Thank you so much. Am requesting you create a more videos in python
@catchalok3
@catchalok3 2 жыл бұрын
This is by far the best explanations which I have come across. Sometimes, speech is fast. For this, I am using playback speed of "0.75" and it works very well for me.
@mohammadarshad8301
@mohammadarshad8301 2 жыл бұрын
I think he has purposely increased the speed because of 2 reasons: 1) He is aware of the fact that when the KZbin video is watched slowing down, it gets recommended to much wider audience and watch time increases. 2) He is confident about the content and so think that no one will think to let go these videos just because it's little' bit faster.
@sungchulyonseiackr
@sungchulyonseiackr 2 жыл бұрын
Simply Great!
@AnupSPai
@AnupSPai 2 жыл бұрын
this helped me a lot, thank you so much!..
@polarbear986
@polarbear986 8 ай бұрын
Very good explanation !!
@sozo4755
@sozo4755 Жыл бұрын
it's very helpful content, thanks
@jpsan1735
@jpsan1735 Жыл бұрын
Thank for your video. It help me a lot to understand the core of python :33
@nunorodrigues5628
@nunorodrigues5628 Жыл бұрын
awesome video mate
@gena8414
@gena8414 5 ай бұрын
very interesting. covers the memory model of python variables really well. Now I can predict the behaviour of code by drawing out a PyObject pointer diagram.
@witoldzolnowski7067
@witoldzolnowski7067 10 ай бұрын
great content, keep up the good work
@ahmedghallab5342
@ahmedghallab5342 11 ай бұрын
شكرا جزيلا 💙💙💙thanks
@lilyzheng2322
@lilyzheng2322 9 ай бұрын
this make so much sense
@fratquintero7402
@fratquintero7402 3 жыл бұрын
Please, make more videos! You are awesome!
@sreekanthpr
@sreekanthpr 3 жыл бұрын
Thanks. I'm working on the next one. Will try to upload it this week itself.
@MagnusAnand
@MagnusAnand 4 ай бұрын
This is a fantastic video and explanation
@sohailshah1574
@sohailshah1574 7 ай бұрын
Please more videos related to python.. what a visualization Thank you so much sir
@Pedritox0953
@Pedritox0953 10 ай бұрын
Great video!
@JohnWickXD
@JohnWickXD Жыл бұрын
Thanku so much!
@hrtrfli2702
@hrtrfli2702 2 жыл бұрын
İt is usefull ,so much , thank you very much.
@MAMUN-zo9tv
@MAMUN-zo9tv Жыл бұрын
Just wow 😍😍😍😍
@manishjain6294
@manishjain6294 Жыл бұрын
Hey Sreekanth. The video is too good. Which book do you read? Request you to give the source of this please.
@armanmalkhasyan4765
@armanmalkhasyan4765 2 жыл бұрын
Thank you very much
@artemtitov8657
@artemtitov8657 2 ай бұрын
BRO U ARE CRAZY!!! ITS FIRE!!! Where do you get such detailed information from? only the source code?
@AnantaAkash.Podder
@AnantaAkash.Podder 8 күн бұрын
Thank You Sir...
@richardharris202
@richardharris202 3 ай бұрын
such a underrated video! what is your linkedin bruh!
@olivierTUBO
@olivierTUBO 2 жыл бұрын
Thanx for doing this
@TechTutorialswithPiyush
@TechTutorialswithPiyush 2 жыл бұрын
That was really amazing, would you be able to share the tools you have used for recording, is that a powerpoint or any other tool? Which application you have used for speech? Really impressed with the way you have delivered! Nailed it
@sreekanthpr
@sreekanthpr 2 жыл бұрын
github.com/3b1b/manim for generating the video. One note >> view >> immersive reader for the audio. Davinci resolve for final mixing of video, audio and subtitles
@TechTutorialswithPiyush
@TechTutorialswithPiyush 2 жыл бұрын
@@sreekanthpr That's awesome! Thank you very much for sharing. I wish you a great success ahead for your channel
@orgoon7697
@orgoon7697 8 ай бұрын
Outstanding, thx
@M.I.S
@M.I.S 10 ай бұрын
thank YOU!
@boutiflet
@boutiflet 3 жыл бұрын
Awesome !
@user-xj8oy3kh4g
@user-xj8oy3kh4g 2 жыл бұрын
great job!
@akmzahidulislam2764
@akmzahidulislam2764 2 жыл бұрын
Excellent explanation. Thanks a lot. Correction: At 9:08, the name of the function should be the same, ie add_ten_to_list. Mistakenly mentioned as add_one_to_list.
@wellhellothere1785
@wellhellothere1785 Жыл бұрын
great video I would slow it down a little bit more, but overall the content is great. Thank you
@umi_nari
@umi_nari 4 ай бұрын
great video thks 🙏
@adrianosymphony
@adrianosymphony 4 ай бұрын
in the time 07:01 (about 'some string' and 'some_string') don't work the same way if you run the code in a file and typing line by line in the interpreter. I tested here in some versions of python and the result was the same. Chat GPT told me why this heppended: "...when you run the code line by line in the Python interpreter, each line is executed independently, and the variables may not be stored in the same memory location. The Python interpreter, especially in interactive mode, may reuse memory for string literals that are equivalent. This is an optimization mechanism known as string interning."
@khardu
@khardu 2 жыл бұрын
Thank you for sharing your hard-work and knowledge for free. Could you please make it a little slower for your future videos. It's hard to keep up with the pace for python beginners and non-natives like me.
@biswajitdas4214
@biswajitdas4214 2 жыл бұрын
Awesome beautiful
@johnlemon9660
@johnlemon9660 2 жыл бұрын
thanks bro! these topics rarely get touched as well as rarely taught visually well. what did you use to make these animations?
@sreekanthpr
@sreekanthpr 2 жыл бұрын
I use github.com/ManimCommunity/manim to generate the video.
@sohailshah1574
@sohailshah1574 7 ай бұрын
Please more videos related to python.. what a visualization Thank you so much sir ... And one more thing, can i use your visualization for Instagram post?
@stephanosc7728
@stephanosc7728 Жыл бұрын
Clear
@ahmedsamir-qw1zp
@ahmedsamir-qw1zp Жыл бұрын
too much helpful, and excellent demonstration ... could you send a reference on this topic to go deeper, please
@Yassine-it6rp
@Yassine-it6rp 5 ай бұрын
so good man
@vvuonghn
@vvuonghn 6 ай бұрын
This video is awesome
@t.m7617
@t.m7617 2 жыл бұрын
04:20 will the PyObject(s) reference count remain 1 no matter how many variables I assign to the PyVarObject?
@user-qs2xl7td2r
@user-qs2xl7td2r Жыл бұрын
Is the term object and value in python equivalent? Or object consider a box and a value is what the box contained?
@tanmaychavan743
@tanmaychavan743 10 ай бұрын
Why did you stop uploading videos 😢, they are so damn Good than any other channels.
@mishalpatel514
@mishalpatel514 2 жыл бұрын
Nice!😊 Could you please tell me from where did you learn this?
@sreekanthpr
@sreekanthpr 2 жыл бұрын
Comments from Python interpreter's source code github.com/python/cpython/blob/f572cbf1faab33d9afbbe3e95738ed6fbe6e48e6/Include/object.h#L9 and some specifics I started to notice when I learn another language and come back to Python.
@mishalpatel514
@mishalpatel514 2 жыл бұрын
@@sreekanthpr That's so cool man! Please keep making more videos.😊
@zeinabezz1426
@zeinabezz1426 Жыл бұрын
First, I'd like to thank you about your very powerful videos You say that list are stored in arrays... But what about tuples, sets, and dictionary??
@ttoommxxmmoott
@ttoommxxmmoott 10 ай бұрын
I wonder how had the brilliant idea to create the += operator, it's just extremely confusing unless you know exactly what you are doing
@mehdichellak4373
@mehdichellak4373 Жыл бұрын
I type the same code as you: x = 42 y = 42 print(x == y) # true print(y is x) # true print(id(x), id(y)) x = -257000 y = -257000 print(x == y) # true print(y is x) # true print(id(x), id(y))
@AA-cr6gd
@AA-cr6gd Жыл бұрын
6
@itsmaxim01
@itsmaxim01 Жыл бұрын
me using try {} catch {} to push items to the immutable array:
@innercircletradertevision
@innercircletradertevision 2 ай бұрын
I am tired
@sohailshah1574
@sohailshah1574 7 ай бұрын
Please more videos related to python.. what a visualization Thank you so much sir
How variables works in Python | Explained with Animations
18:39
ТАМАЕВ vs ВЕНГАЛБИ. ФИНАЛЬНАЯ ГОНКА! BMW M5 против CLS
47:36
Её Старший Брат Настоящий Джентельмен ❤️
00:18
Глеб Рандалайнен
Рет қаралды 9 МЛН
ОДИН ДЕНЬ ИЗ ДЕТСТВА❤️ #shorts
00:59
BATEK_OFFICIAL
Рет қаралды 4,9 МЛН
Memory Management in Python - The Basics
30:27
North Bay Python
Рет қаралды 33 М.
Closures in Python | Explained with animations
8:08
Sreekanth
Рет қаралды 23 М.
This Is Why Python Data Classes Are Awesome
22:19
ArjanCodes
Рет қаралды 792 М.
What is the Python Interpreter? (How does Python Work?)
14:08
Afternerd
Рет қаралды 75 М.
All Rust features explained
21:30
Let's Get Rusty
Рет қаралды 286 М.
5 Good Python Habits
17:35
Indently
Рет қаралды 387 М.
ТАМАЕВ vs ВЕНГАЛБИ. ФИНАЛЬНАЯ ГОНКА! BMW M5 против CLS
47:36