Even before starting the video I know that it's going to be awesome. Kudos Fred ! Would love a series on implementing various design patterns using python.
I just finished the udemy deepdive-1 and now half-way deepdive-2. But could not resist to watch this stand-alone course video right now. This is also a great video with the same level of detail as the deepdive series. Great added value !!! 😀
Thanks for all the work you do. Your python lectures are best I've seen. Just as a suggestion... you should include a 30 second advert for your udemy courses at the start of each of your TH-cam videos. This would help those looking to learn Python as well as grow your Udemy following
Thanks! Glad you like the videos. I do add them to the video description - not sure how people would tolerate a 30 second ad for my courses at the beginning of the videos - maybe I should look into cards instead...
@@mathbyteacademy Yes, displaying a card which links to an advert video (which gives a comprehensive description of your Udemy courses) is an excellent idea! I think very few people actually read the video descriptions. And experimenting with different approaches, and then analyzing their impact, will help you find the optimal approach. Good luck!
Hi Fred, Great video,!! thanks for sharing the "in deep" of things.! I was wondering if sometime in the future you could do some comparison between attrs and dataclasses and when to use one or the other. Big kudos!!
You are amazing Fred. Everytime I open youtube app, I check if you released new video. Awesome explanation. Can you please make videos on Machine learning concepts and maths required for machine learning?
Not really. I use pydantic primarily, but that's because most of the projects I work on already have a dependency on pydantic. Otherwise I might use a dataclass, or maybe just a named tuple.
Hey Fred, great breadth and depth as always. A question regarding dataclasses sorting 47:15 , would using a __post_init__ method be an alternative to sort using radius and/or euclidean distance, for example ``` @dataclass(order=True) class CircleD: sort_index: int = field(init=False, repr=False) euclidean_dist: float = field(init=False, repr=False) x: int = 0 y: int = 0 radius: int = 1 def __post_init__(self): self.sort_index = self.radius self.euclidean_dist = dist((0,0), (self.x, self.y)) ```
Hi Fred, thank You for another great content and such explanation. Have a small question. 24:20 You added private attributes x, y and radius. Should we also make them private in all other methods __repr__, __eq__ and __hash__? Because it looks like You did not make them private in those methods and in the video they only private in properties You add.
Best practice is to use accessor methods if present. Sometimes you might want to circumvent the accessor methods and read/write the "private" backing variables, but most often you just use the accessors.
Thank you, glad you like them. No particular plans on data structures, but I do have a video on deques vs lists coming up next in the channel. I'll keep it in mind!
Hi Fred, thanks for creating these wonderful lessons. I am trying to understand how python is letting us allow a dictionary with duplicate keys (minute 23.35) in the video, what 's the explanation here, i was expecting the second circle to overwrite the first entry
Thanks, glad you like them. So dictionaries cannot have duplicate entries. The two objects you see there are different objects (if you could retrieve each one you'd observe that they have a different id, they started life out that way), but because we mutated one of the objects to now be equal (in terms of their == and hash) to the other, the two objects have different id's, but as far as the dictionary is concerned they are the "same" object and things get totally weird. Bottom line, you should not use mutable objects as keys of a dictionary.
I have thought about it many times - but I keep getting stuck on Windows vs Linux/Mac. I don't use Windows at all (haven't touched it in like over a decade), and a lot of the "real" projects I work on involve nix command line tools, including things like Makefiles, bash scripts, ci/cd pipelines, etc. I think a majority of Udemy students are on Windows, so that's why I keep getting stuck :-)
@@mathbyteacademy Ohhhh, that sounds more interesting to me now !! I want to learn bash scripts and Makefiles etc and I use Linux. Fred, I really hope that you somehow someway make that course on Udemy eventually. If not, I hope that you make it on youtube member channel so that those who want to learn it pay for it, I will definitely pay for that !
@@mathbyteacademy Makefiles, bash scripts, ci/cd pipelines sounds really good, can we expect some video on this subject?) By the way what tools do you prefer to use for ci/cd pipelines?
To be honest I didnt know about dataclasses so I was just using normal classes with __slots__, but 95% of what dataclasses do I was already doing with inheritance, only had to write the __repr__ and all that once, plus most of the dunder methods are useless. But yeah I will switch to dataclasses to avoid writing the __init__, but thats about it
What do you mean "most of the dunder methods are useless"? You mean like __eq__, __hash__, __gt__, __iter__, __next__, etc? If you think those are useless, may rephrase it to "useless to me", because I can assure you they are very useful and used extensively by Python devs (depending on the circumstances).
Im not an expert but I think your size comparisons are wrong. When u do the os.size or whatever, it only gives you part of the info on size, I seem to remember only like the reference to the class or something, i.e. a class with one attr will be the same size apparently as one with 100
@@mathbyteacademy O sorry, maybe you did measured the sizes properly but then the sizes look wrong too because they are too similar. I mean in the table were you compare the sizes and speeds at the end of the video.
So, the library I use handles looking inside objects to get the full memory usage. Why are you surprised that the sizes are too similar? At the end of the day, named tuples are actual classes, dataclasses are well, regular classes, and slots do tend to be more efficient than not, but these are small classes, so i would expect difference to be quite small (in absolute terms), and indeed we can see the slots versions use less memory. The numbers I have in that table make sense to me.
Hey Fred - You never fail to amaze your students. You are such a gifted teacher who can simplify anything and everything. Big kudos to you.
Thank you so much!
You are the best Fred, thank you very much for sharing your knowledge
You're welcome!
Am excited to watch this when I get the chance.🎉
I happy to hear your familiar voice, I didn't know what's your TH-cam channel before
Even before starting the video I know that it's going to be awesome. Kudos Fred ! Would love a series on implementing various design patterns using python.
Thanks!
I just finished the udemy deepdive-1 and now half-way deepdive-2. But could not resist to watch this stand-alone course video right now. This is also a great video with the same level of detail as the deepdive series. Great added value !!! 😀
Glad it was helpful!
Amazing video! That is a lot of great information. I thought I knew enough of dataclasses but learned a lot in this video. Thanks!
Glad you liked it!
Oh! I can't resist to write a comment here! It was a very deep dive in dataclasses! Perfect material! Thank you very much!!!
glad you liked it, thanks!
Hey Fred - your courses are GOLD
Thanks!
Just Excellent!
Thanks!
Thanks for all the work you do. Your python lectures are best I've seen. Just as a suggestion... you should include a 30 second advert for your udemy courses at the start of each of your TH-cam videos. This would help those looking to learn Python as well as grow your Udemy following
Thanks! Glad you like the videos. I do add them to the video description - not sure how people would tolerate a 30 second ad for my courses at the beginning of the videos - maybe I should look into cards instead...
@@mathbyteacademy Yes, displaying a card which links to an advert video (which gives a comprehensive description of your Udemy courses) is an excellent idea! I think very few people actually read the video descriptions. And experimenting with different approaches, and then analyzing their impact, will help you find the optimal approach. Good luck!
I think it might even be worthwhile creating a professional avert for your Udemy courses and then running it on TH-cam Ads
@MathByte Academy Fred your courses are some of the best in existence definitely promote them!
Great lecture on dataclasees Fred, I especially enjoyed the comparison section with name tuples. Can't wait for the follow up video.
Thanks!
Hi Fred, Great video,!! thanks for sharing the "in deep" of things.! I was wondering if sometime in the future you could do some comparison between attrs and dataclasses and when to use one or the other. Big kudos!!
Thanks! Yes, I am currently working on something like that, but it's taking me a while to come up with something that's not just superficial.
Great explanation
Glad you liked it!
Great video thanks
You're welcome!
You are amazing Fred. Everytime I open youtube app, I check if you released new video. Awesome explanation. Can you please make videos on Machine learning concepts and maths required for machine learning?
Thank you!
Thanks! Did you start using dataclass more often? In which cases?
Not really. I use pydantic primarily, but that's because most of the projects I work on already have a dependency on pydantic. Otherwise I might use a dataclass, or maybe just a named tuple.
Hey Fred, great breadth and depth as always.
A question regarding dataclasses sorting 47:15 , would using a __post_init__ method be an alternative to sort using radius and/or euclidean distance, for example
```
@dataclass(order=True)
class CircleD:
sort_index: int = field(init=False, repr=False)
euclidean_dist: float = field(init=False, repr=False)
x: int = 0
y: int = 0
radius: int = 1
def __post_init__(self):
self.sort_index = self.radius
self.euclidean_dist = dist((0,0), (self.x, self.y))
```
Hi Fred, thank You for another great content and such explanation. Have a small question.
24:20 You added private attributes x, y and radius. Should we also make them private in all other methods __repr__, __eq__ and __hash__? Because it looks like You did not make them private in those methods and in the video they only private in properties You add.
Best practice is to use accessor methods if present. Sometimes you might want to circumvent the accessor methods and read/write the "private" backing variables, but most often you just use the accessors.
I love your videos, amazing content in Udemy and TH-cam. Any plans of making a playlist on Data Structures and algorithms😀
Thank you, glad you like them. No particular plans on data structures, but I do have a video on deques vs lists coming up next in the channel. I'll keep it in mind!
Hi Fred, thanks for creating these wonderful lessons. I am trying to understand how python is letting us allow a dictionary with duplicate keys (minute 23.35) in the video, what 's the explanation here, i was expecting the second circle to overwrite the first entry
Thanks, glad you like them. So dictionaries cannot have duplicate entries. The two objects you see there are different objects (if you could retrieve each one you'd observe that they have a different id, they started life out that way), but because we mutated one of the objects to now be equal (in terms of their == and hash) to the other, the two objects have different id's, but as far as the dictionary is concerned they are the "same" object and things get totally weird. Bottom line, you should not use mutable objects as keys of a dictionary.
Thanks!
Thank you Peter!!
Hi Fred, will you ever make a course on Udemy about making interesting projects using all different techniques of Python? I would love it!!
I have thought about it many times - but I keep getting stuck on Windows vs Linux/Mac. I don't use Windows at all (haven't touched it in like over a decade), and a lot of the "real" projects I work on involve nix command line tools, including things like Makefiles, bash scripts, ci/cd pipelines, etc. I think a majority of Udemy students are on Windows, so that's why I keep getting stuck :-)
@@mathbyteacademy Ohhhh, that sounds more interesting to me now !! I want to learn bash scripts and Makefiles etc and I use Linux. Fred, I really hope that you somehow someway make that course on Udemy eventually. If not, I hope that you make it on youtube member channel so that those who want to learn it pay for it, I will definitely pay for that !
@@mathbyteacademy Makefiles, bash scripts, ci/cd pipelines sounds really good, can we expect some video on this subject?)
By the way what tools do you prefer to use for ci/cd pipelines?
@@mathbyteacademy Do it for the ones that are on Linux! :). I'm working at Microsoft and we use mainly Linux OS in Azure!
To be honest I didnt know about dataclasses so I was just using normal classes with __slots__, but 95% of what dataclasses do I was already doing with inheritance, only had to write the __repr__ and all that once, plus most of the dunder methods are useless. But yeah I will switch to dataclasses to avoid writing the __init__, but thats about it
What do you mean "most of the dunder methods are useless"? You mean like __eq__, __hash__, __gt__, __iter__, __next__, etc? If you think those are useless, may rephrase it to "useless to me", because I can assure you they are very useful and used extensively by Python devs (depending on the circumstances).
Im not an expert but I think your size comparisons are wrong. When u do the os.size or whatever, it only gives you part of the info on size, I seem to remember only like the reference to the class or something, i.e. a class with one attr will be the same size apparently as one with 100
Where do I use os.size? I'm looking at the code notebook, and doesn't look like I do.
I am well aware of the limitations of os.size.
@@mathbyteacademy O sorry, maybe you did measured the sizes properly but then the sizes look wrong too because they are too similar. I mean in the table were you compare the sizes and speeds at the end of the video.
So, the library I use handles looking inside objects to get the full memory usage. Why are you surprised that the sizes are too similar? At the end of the day, named tuples are actual classes, dataclasses are well, regular classes, and slots do tend to be more efficient than not, but these are small classes, so i would expect difference to be quite small (in absolute terms), and indeed we can see the slots versions use less memory. The numbers I have in that table make sense to me.