Hi! This past week we covered quite a bit of content. Some of those things include read-only pointers. Those were something that I had never understood at all in the past. I always assumed that const pointers were pointers that could not actually change.

That finally clicked in class, though, when we learned about how the different data structures work in Python. I had always wondered why it was possible to use tuples as a key for dictionaries, but didn’t understand why it didn’t work with lists. That made a lot more sense to me when I learned that the lists were mutable but tuples were not. That means that hashing a tuple is possible while a list cannot be guaranteed.

Additionally, I really learned more about how reduce works. Seeing that the self variable actually gets used in python class methods was very useful. Also, I had heard about the usefulness of reduce and map, but hadn’t actually seen it firsthand. Now, I understand why they could be useful in getting a single value. Instead of having to write a huge for loop, I could just write an optimized reduce function. I also learned that the code was quicker in that case as well, which is really cool!

That idea of optimizing certain things was cool to me, but it was disappointing to see that optimizing things like tail recursion are not possible in Python. That’s because of it’s interpreted nature and the lack of the just in time compiler (JIT) to be able to find those optimizations at runtime. I still really enjoyed that lesson!

For my tip of the week, I want to talk about compiler explorer. As something that is very relevant to programming in general, I think it is useful to know how your code can get optimized or cleaned up in ways. Compiler Explorer (or GodBolt) helps by annotating code and showing your code side-by-side with the compiled output (and lets you even choose the optimization levels!). That makes it possible to understand some optimizations without even understanding how a compiler works.