Ask HN: Is it worth it to learn C to better understand Python?
For those who learned C after learning Python, was it worth it? Did it help you to better understand Python? In college I used to tutor students in computer science. Mid-way through my college career my school switched the curriculum to teach Python instead of Java. I found that the students who took Python lacked what I considered a basic appreciation for and understanding of how the language actually ‘does’ something. For instance, when you only need to write two curly braces to create a “dictionary” (of course behind the scenes this is a hash table) many of the nuances of that data structure are hidden from you. You have no idea that accesses are O(1) amortized but worst case are O(n). Even if you do, maybe you don’t understand why. You have no idea that there is reallocation and collision handling code working behind the scenes constantly. Python also lacks a number of nuances I consider it important to be aware of. You live your entire Python life blissfully unaware that everything is a pointer, and the impact that has on performance. You never come across static typing, or that it is possible to check your code for some level of syntactic correctness before it runs (i.e. Python is interpreted rather than compiled). I think from this standpoint, it is worth learning a language like C to gain an appreciation for how truly complex a lot of the things Python allows you to do, are. I think that anything which helps you better understand what it is you are doing, how you are doing it, and why you are doing it that way, will make you better at doing that thing. There are certainly some advantages to be gained from greater mechanical sympathy and an appreciation of static types. However, in the modern day, I wouldn't suggest a Python programmer learn C to achieve either of these things. For a Python programmer who just wants to learn about static type systems, learn Typescript. For a Python programmer who wants to learn about static type systems and mess around with pointers, learn Go. For a Python programmer who really wants to get elbow-deep in a natively-compiled language with a fairly sophisticated type system, learn Rust. For someone who doesn't want to actually use C and just wants to learn concepts, C doesn't really have any advantages these days. Its type system is anemic, its compilers are unhelpful, its abstractive capabilities are poor and leaky, and its claims of being close-to-the-metal are overblown on modern processors. There are plenty of good reasons to learn C, but IMO "to become a better Python programmer" is not one of them. This is a fair point. Most of my response is driven by the fact that I think there is value in understanding a lot of the behind-the-scenes things that the language does, so I mostly agree. Really, I’d suggest learning as many languages as possible - they influence the way you think about the code you are writing and having the different perspectives allows you to broaden your horizons and see what else is possible. Eventually, this is how you form your opinions on what makes a programming language “good” and allows you to contribute to the decisions we all make daily over what technology to use and what becomes popular. I still do think there is value in learning C, though. Of extant languages (disregarding assembly), I believe C is the ancestor of nearly every programming language today. From a historical perspective, understanding C and it’s shortcomings allow you to understand the motivations that created even higher level languages. Similarly, it would be hard to understand a lot of the decisions the C language makes without an understanding of assembly, why assembly instructions are as they are without understanding computer architecture, etc. There is also an argument to be made that C is still extremely ubiquitous. I like Rust as a language very much and think there is a great deal to learn from it, but it is still so immature (though it has come a long way) that I would feel disingenuous suggesting it to someone who only knows python as a way to gain a better understanding of programming languages. I imagine it would be akin to encouraging a Buddhist to practice Lutheranism shortly after Luther’s schism rather than learn about Catholicism first - someone who does so would be blindly ignoring all the history and motives that drove that change in the first place. Those are all vastly more complicated than C. And on top of that you have to learn three instead of just one! (Imagine trying to learn Rust without experience with C. Oh man.) I think many programmers forget how it was to learn to program. Imagine the horror trying to make Rusts borrow checker happy without even understanding what an object scope or pointer is. C is a really good beginner's language, since any oop is explicit with function calls, kinda like Basic. No invisible destructors etc. Modern compilers even warns you on returning pointers to stack locals etc. I don't think Python is a good beginners language anymore with all its complexity. Maybe Go or Java. > I don't think Python is a good beginners language anymore with all its complexity It's not like the simpler parts of the language have gone away in recent versions. You can still program in python like it's 2.7. Just as you can still program in C++ using C paradigms. Agreed. C is a great starting point. It's a terrible continuing point though. Novice C programmers write seg-faulty code left and right, which is fine. That's not a problem; everything that's wrong is on the surface. In the mean time, they've learned how to implement a binary search tree or something, which is pretty cool when you do it in C. The intermediate two-star C programmer whose programs almost never segfault, that's the truly dangerous one. Precious few C programmers make it past that stage. Ye, unless you to electrical engineering/close to hardware embedded or something. However even those probably benefits from mastering some memory managed language, before going back to C. Good points. Though it would be a good debate that Go would be a better beginner language. Java's forcing of class based OOP would cause an avalanche of other kinds of problems that Go and C don't have to deal with. Other than the 3 lines of boilerplate for the main method, Java ain’t forcing anything. You can write FP with it as well. Also, it is probably better to get started with the much more common nominal typing over structural. > Imagine trying to learn Rust without experience with C. Oh man. I don't think it's that bad - primarily because error messages are way more helpful, but also because it'll error about things that C would just choke on at runtime. (I learnt/continue to learn Rust with only 'university C', fwiw.) > Those are all vastly more complicated than C. C's simplicity is an illusion. The vast quantity of footguns and edge cases make writing correct C extremely complicated. > And on top of that you have to learn three instead of just one! You don't need to learn all of those, select one based on what your goals are. And it's not like gaining a surface-level understanding of any of these programming languages would take more than a week to a month anyway. > Imagine trying to learn Rust without experience with C. Oh man. It's quite the opposite. Rust is a dream to learn compared to C. The Rust compiler is like having a personal tutor at your beck and call to teach you systems programming best-practices. Without exaggeration, these days I would not suggest someone start learning C until they have learned Rust. They aren’t necessarily advocating learning C so that they can write lots of production code in C. They are advocating learning C to better understand lower layers of programming. The basics of C are easy and illustrative. And given that the main Python interpreter is written in C, can be helpful to know. Thank you. This was well explanined. Once again thanks for this. I am learning and will continue learning Python and Js. However, when I decide to pick a static language I will definielty be going for Go. For many people (myself included), the ease of writing python jumpstarted my journey to eventually learning everything else you mentioned gradually. If I would have had to learn it immediately I most likely would’ve felt disinterested and overwhelmed and given up since I didn’t know yet why I needed to learn it. This is my major gripe with the college courses I took. They start at the molecular level and build to the planetary scale. This works for some people, but for me I had the hardest time finding a personal interest until I got to the application. It was the application I wanted to build, and to do actual work you don't manipulate the molecules directly. Build an application, then as you need to learn more to get things done you naturally pick up a deeper knowledge of the tech you're using. Of course this is different for everyone. Yup yup yup. I've been coming to this realization about myself so much recently too. It's how I taught myself web/app dev with hackathons, facing a huge project head-on and "backtracking" to learn stuff as needed. It's how I taught myself machine learning by jumping into a research project with a prof without ever having written PyTorch. And it's how I'm now teaching myself higher math, having just jumped into the homotopy type theory textbook and an idea I have for application in NLP, and going backwards to learn the required category theory and algebraic topology. I wonder whether the fundamental structure of curricula could be changed to take advantage of this fact, because I think it's true for a lot of people. Agreed. I've found the insistence my college professors had on writing everything yourself and not using libraries or modules for common tasks to be in the end counter productive. Namely for the reason you described. To reference Carl Sagan, I didn't have the stamina in the beginning to build the universe before I made my apple pie. Additionally, code is more collaborative than that, and it shows in a lot of engineering departments when people aren't trained on how to look at the shelf for existing parts before building something new. >when you only need to write two curly braces to create a “dictionary” (of course behind the scenes this is a hash table) many of the nuances of that data structure are hidden from you. You have no idea that accesses are on average O(1) but worst case are O(n). Well, that is wrong. Single value accesses are O(1) amortized. Also, Java is a lower level language but I don’t think simply programming in Java instead teaches you this. Either way, it’s the difference between learning how to write programs and learning computer science. Updated the original comment accordingly. I suppose that’s also fair. I would say that Java at least makes you aware that there is magic afoot. You have to explicitly write that you’d like to use a HashMap, at which point someone writing or reading the code might wonder “what’s that?” Instead, python hides behind the abstraction of a “dictionary” when it should be in my opinion broadcasted from the high heavens that this is a hash map in disguise. As far as the remainder of your comment, I agree wholeheartedly. Learn computer science. It makes you a better programmer. Yeah, that’s true. Calling it a “dictionary” definitely doesn’t help! I would support any and all efforts to stop inventing new words for established constructs. I learned to program with Python and I am confident these things held me back, now that you mention it. You got me curious there. Do you have any resource recommendation to learn about the cost of different data structures/algos and such? This is what big O (also little O and little omega) notation is all about. Unfortunately, all the resources I know of teach it as pure mathematics, so they require a firm grasp of mathematical proofs to understand the details and implications. With that said I highly recommend the classic Introduction to Algorithms (CLRS for short) by Cormen et Al. It is written in clear and straightforward language. And the lectures on MIT OCW by Erik Demaine are outstanding. By reading and watching the lectures I deeply understood stuff that I had just muddled through previously. Introduction to Algorithms is a classic that every serious programmer should read cover to cover. at my first programming job (now almost 30 years ago), I remember implementing the red-black tree algorithms in C from that book. It is chock full of really useful ideas that will make your systems better. CLRS is the text, but for a more gentle introduction see Grokking Algorithms. Ideally you'd teach python to build a c compiler. ;) That said do people know more about the innards of Java ? It shield you from a lot of details too. From memory layout, to polymorphic calls. From https://news.ycombinator.com/item?id=28709239 : > From "Ask HN: Is it worth it to learn C in 2020?" https://news.ycombinator.com/item?id=21878372 : (which discusses [bounded] memory management) > There are a number of coding guidelines e.g. for safety-critical systems where bounded running time and resource consumption are essential. *These coding guidelines and standards are basically only available for C, C++, and Ada.* > awesome-safety-critical > Software safety standards: https://awesome-safety-critical.readthedocs.io/en/latest/#so... > awesome-safety-critical > Coding Guidelines: https://awesome-safety-critical.readthedocs.io/en/latest/#co... It seems like many of these problems were holes in the curriculum more than weaknesses in Python. However, modern python has type annotations, which help a lot with checking the program for correctness. I would say every one of these concepts can be taught with effective curriculum using modern Python. Now, I still think one studying computer science would be well served to learn C at some point! But Python is a great replacement for Java in the curriculum. I agree with everything you said, and feel exactly the same way; except my university switched from C to Java mid-way my attendance... so it probably just goes to show something or the other :-> I always liked the stick shift versus automatic for drivers ed analogy. Yet in an era where inclusiveness and student retention are deemed more important than foundational learning, its no wonder Python is getting mass adoption. None of that pays the mortgage, though. I think every coder who have the time to do so should learn C. Preferably before anything else.
Maybe I'm biased by my education, since I started with almost a year of hardcore C(almost no libs, coding everything from scratch), I did code a bit before but nothing serious.
After 1 year of segfaults, memory leaks, and random buffer overflows, everything else seems pretty easy, and everything make much more sense. You won't just get better at python, you'll get better at pretty much anything involving programming or understanding how a computer works. I've seen a lot of people say that if you learn C well, you're basically employable for the next 30 years. I think I agree with that. > if you learn C well, you're basically employable for the next 30 years. I think I agree with that. In embedded systems programming, right? It must take significant C expertise and experience to be gainfully employed. Maybe I'm overthinking it? I agree with you, and at the same time, I notice your username says throwaway. It seems liking the C language is frowned upon in this site. Yes. Learn C. Not to understand python, but to become a better programmer and gain a better understanding of computers. We desperately need more people learning the 'hard' languages. Python is fun, but libssl, libcurl, the Linux kernel, and all the other 'important' things need more developers. Exactly. Learn multiple languages. Not really 'all of them' or all super in-depth, but if you want to do more than complete simple pre-cooked tasks of a to-do list (or JIRA board) you'll probably need to understand a bit more about the how/what/why. Learning more languages or different languages will let you see the similarities and differences but also the way they all end up running on the same system, calling into the same libraries and operating system. That said, languages are generally just 'ways to write', often aligned with 'ways to think' but they aren't themselves the algorithmic and data structural concepts which are very useful to at least know and have played around with a bit. It doesn't mean you actually end up re-implementing every doubly linked-list in all your code, but knowing the concept of hashing and binary trees, seeing how they can be helpful in hashmaps, and how turning arrays into trees and back again gets you so much extra understanding that when you do finally end up writing some production code and needing to make it work faster, use bigger datasets or reduce cost by optimising resource usage you'll at least know where to look and what to search for in your refactoring spree. Learning C and perhaps C++ is great for writing system libraries that need to run close to the metal, but I wouldn't really want programmers to still use those languages in general software development. If Go and Rust gets you there 90% of the way and you can glue things together with Python, Lua and other stuff you'll be able to make reasonable software for general use which is what most development ends up being anyway. Java (and C#) are still there of course, and you'll still want to at least play around with those just to get a sense of the (software world) around you. The time that you just boxed yourself in with 1 OS, 1 IDE and 1 Language with 1 Framework is passing (or has mostly passed) in commercial development. Throwing raw source code over the fence for 'ops' to do the rest is dying off. No, it won't help you better understand Python. However, for professional development, you should probably learn it anyways before you jump into other lower level languages. C is the Latin of programming languages, as it's the common root of a flurry of languages, and you see it's influence in a lot of places. Even though it's not exactly "how a computer works," understanding its purpose and problems puts other languages into context. I learnt C around the same time when I was learning Python and I don't believe it had much of an impact on the latter. Unless you're building a Python interpreter, I don't see how it can help with learning the language. While C has served me and many others well, I don't think it should come before learning a modern alternative like Rust or Go. Yes, but in my experience it will teach you more about the layer beneath (the machine) than it will about the layer above (Python.) The technology we call “C” is not just the language — it’s the whole system of language, preprocessor, compiler, linker, assembler and debugger that comes together to produce and inspect machine code. In terms of computing machinery, there is no more fundamental target than this. Accordingly, you should learn enough about the C ecosystem to be able to debug a C program. It’s enough to be able to read code in C, but you will want to write some to get a feeling for the culture (passing the address of where you want the result of a function as a function argument is the big one, and it’s accompanying subtasks around memory management and pointers.) You don’t have to go inside the compiler itself but I would recommend looking at some simple machine code and trying to assemble some yourself. You could do this on arm or x86, or on an emulator like this one for high school students: https://www.peterhigginson.co.uk/AQA/info.html Once you build a sufficiently complex bit of assembly code you’re going to want to extract out common “functions” and give them names, and develop a convention for how to use memory, which registers do what when you call a function. That’s what a C compiler actually does. NO! You should learn some more fundamental aspects of programming: 1. What's the stack, what's the heap, why do I get a stack overflow from recursion? 2. In C, what's a pointer, how does it relate to arrays? 3. What's garbage collection, and how does it work? And that will eventually lead you to the inevitable: 4. Why is Python so slow? (haha - getting ready for the downvotes!) It’s not clear what is meant by “to better understand Python”. Better understand CPython, e.g. and you want to hack on the interpreter, or better understand how to write more creative/abstract/safe Python? In my experience Python programmers can be divided into two groups, those who write Python and those who write Python frameworks, aka Python for other Python programmers. The latter group is trying to create an abstraction that helps solve a problem in an elegant way. Often to do that a deep understand of the language is needed such as the use of descriptors, higher order functions, the Python object model, metaclasses. One of the best books for this is “Fluent Python”. It’s also a good to browse around significant projects and understand how they work and what patterns are used, eg Django, Flask, etc. Python is so far removed from C that I struggle to think of anything about C that would help you to better write or understand Python. If anything, it might make your Python worse if you try to import C idioms to Python. If what you really want is to write or read C, then of course you should learn C. given that python is usually implemented in c (look up cpython), knowing c can help you at least understand internals of python Unless you want to contribute to CPython, no. What about Python are you trying to understand? You can learn more about Python internals without needing too much C. And you can get better at Python without knowing much about the internals or C. So it looks like a waste of time. No. Would you then learn assembly to understand C better?
Once you have the basics of syntax and semantics your next step is the OOP and FP paradigms used in Python for simple programs.
Then a deep dive for a solid grasp of data structures and algorithms would be the last step.
After you have these 3, you should be able to write mid to high level programs comfortably. Which of these 3 aspects do you feel C would help you understand better? Maybe you are asking this question because you want to understand programming languages and how they work in which case a course in compilers and programming languages from a MOOC would help. Most Python programmers will struggle with the lack of comparable functionality in the standard C lib. How do you tell a Python programmer that in C to use sets or a hash or a dictionary, that you need to implement them yourself or find a third party library? Also, how do you explain the C compile-link-run process to a Python programmer who only knows that Python just runs? A lot of basics are missing in C and in Python Programmers. Maybe guide them to C++ for standard template library equivalence. But then you have another ocean of pain because C++ is the kitchen sink. On a long enough timeline even dynamic languages want static types. Looking at you JS/ Typescript. Yes learning C gives you an appreciation of how types “as simple as” a String in Python is constructed. I never got too far into C, but I took a course on assembly and learned Erlang and Golang to a decent proficiency. Erlang gave me an appreciation of loops and recursion, Golang made me more aware of types and error handling, and assembly just made me happy that I don’t have to write assembly. All this of this made me a significantly better Python programmer and made me appreciate what was going on under the covers a bit more. I also find value in challenges like advent of code, because it gives me a chance to tinker with a language in new ways. Would you learn how to fly a plane to better understand how a car works? The answer is no of course. You learn more of Python and its internal workings to understand Python better. Python instructor and C programmer here: No need to learn C to better understand Python. Almost any gain you would make could be had by reading or watching an overview of the internals. Yes! Or at least a language that gives you access to manual memory allocations. I learned python, JavaScript, and Java before C, and it wasn’t until I learned about manual allocations, pass-by-value, and pointers that the garbage collected languages made sense. It had never really clicked why all object params are references in those languages until I learned C and C++ Now, I don’t think it’s essential, but learning more about how computers and memory operate doesn’t hurt! Once you start hitting Python’s limits, understanding how the interpreter works (which is implemented in C) will be of great help. You could take weeks 1-5 of CS50 [1] to learn enough C to get by. The course continues from week 6 with Python so it’s the perfect intro. Learn both at the same time :) But, the twist is start from a higher level algebraic problem, like a generalized N-dimensional distance function. Get started with enough Python to do it in two dimensions, then translate the core of your algorithm to Cython and compare the benchmarks. This will get you up to speed with the build processes progressing towards pure C in comparison to plain old interpreted Python. Are you using floats or integers? How accurate is it compared to using a calculator etc. as the numbers get much bigger or have many more numbers after the decimal point. Then, what about the median distance of two arrays of 2d coordinates? Again, benchmark, try out some different approaches to the problem in both languages and see where the different strengths lie, wrapping your head around how programs interface with each other internally across domains - because that's what it's all about right? Now... what about 3 dimensions? Or four? I hope you see where I'm going here, if you're looking for a fundamental understanding then you need to get into the nitty gritty - albeit with a conceptually very straightforward problem. I think unironically learning assembly helped me the most in understanding the computer itself,I don't know about understanding Python through this manner.But through this fashion you can get an idea of how functions are made and operate.I feel like the jump between asm and C & 'higher' languages is bigger than the one between C and Python. I don't think the mental step between C and assembler is that big. You got almost no constructs in C that does not map directly to assembler, like function overloading or classes. The confusion starts when the optimzer throws around your code and makes it unreadable. What do you want to understand about Python? To understand the performance of Python it's more important to understand how CPUs work, but C doesn't help much there. If you look up how e.g. a hash table is implemented at the low level it should give you and idea how the "standard library" and dicts of Python work. I learned C and have worked with C++ professionally in the past and that knowledge doesn't help at all with understanding what Python is doing internally. Sure, CPython is written in C, but that fact doesn't tell you anything about the details of how it's implemented or what it does when it runs. are you saying that if you want to learn the internals of cpython you don't need to know c before hand? i think learning c is a must for this case No, I'm saying C is not enough on its own. sure there is much more to it than just knowing c, but learning it should be encouraged as an important stepping stone if someone wants to learn cpython internals ... or even internals of many (most?) popular python libraries The point of learning C as a python developer isn't to learn C nearly as much as it is to better understand what's going on in the levels of abstraction below. Many years ago, as a student, a friend let me borrow their copy of "Hacking: The Art of Exploitation". At the time I thought I was going to be learning about security. What I learned instead was what a program was, what a computer was, at a surprising level of detail. Especially the early chapters, a true picture of what computers are doing is given to the reader. And once you understand that, you could apply the knowledge to security, no doubt. But you could also apply it to understanding many higher level languages- Python included. You can find older editions online as PDF files. Really recommend it. Do we need to learn assembler to understand C well enough? That’s a litmus test for this question. Well enough? No. To understand it better? Possibly. Whether it is true for C and Python I don't really have an opinion. A friend just finished a beginning Scheme + Java class, and asked me: How are languages like C++, golang, Rust, Lisp, Scala, and Python different. Any pointers to a good video on the topic? "Overview/Survey of features in programming languages"? Thanks. Yes, because learning C will teach you about computing and how your computer works. However C is not the only language that could teach you and you don't have to become fluent in it to understand enough to help your Python. Learning enough about a few languages (i.e being able to write something in them) will help you appreciate what Python does for you behind the scenes, but also how Python limits what you can do with it. Ultimately, if you master Python, you may want to write some packages for it that aren't written in Python and then C is a sensible choice. Yes, learn C. Then play with the ctypes Python module and invoke your C code from Python. Probably. If you should look at the python implementation and the standard libraries it uses and the kernel you are using they are all primarily in C and in rare cases of other languages they are setup with FFI that favors the thought process of a C programmer. When I look at a language like python or PHP I often just go down to the C code they call and use a tracer to watch calls to solve a problem without actually using the higher language. I advocate learning ASM to understand the machine; C and python are the same relation one step of abstraction up. So yes, more knowledge of C and how Python is written and what the interpreter is doing with your code is very likely to be helpful. Interfacing with python with your own C code is easy and the combination of the two is a much more powerful tool than either alone. I would say it depends on what you want to do. I would choose Python for fast prototyping and proofing-of-concepts, C for performance-intensive apps. I'd really rather recommend Nim [1] for performance-intensive apps. Its syntax resembles Python, it is far and away safer, but it complies (via generating C) to a full binary, and the resulting binary is very fast. Don't let the fact that it has a garbage collector scare you -- you can turn it off if you don't like it. Python has a much stronger relationship to C than Nim. Thus many would argue it would be a better recommendation to learn C, if a Python user. In the case of Nim, it would arguably be a language to learn instead of Python, as oppose to somebody who is already an advanced Python user. Other strong choices of newer languages to choose from would be Golang, Rust, Red, or Vlang. Let me ask that same question from the other direction: If you're a (reasonably proficient) C programmer, is learning to use Python worth the effort? Or is it just redundant education? I can see that learning Python is probably worth it for a new programmer, but is it worth it for a proficient C programmer? [Let the flame wars begin!] I'm very comfortable with both, and there are definitely still use cases where I'll reach for Python. E.g., Jax "just works" for a wide variety of numerical problems, handles the automatic differentiation and operator fusion and whatnot and figures out how to efficiently shove it onto whichever coprocessor(s) I want to target. I think it's more about the projects you work on than the language you use. C is a system programming language and most appropriate projects are compilers, operating system, classic console programming, embedded system programming and other low level stuffs. I think you should learn nim programming language against C. Yes, because nim can exporting C code when you write python syntax like nim language. Not all of them, also you can port as javascript and C++. Just try it out. Easy to learn, better way to write C and absolutely worth. Do you know any source to better study how python works? I mean something which are the steps to understand the internal CPython bindings and so on?
I really want to step-up my Python skills but this part seems really hard for people with a non CS related background. I can recommend https://realpython.com/products/cpython-internals-book/ as a decent initial documentation of cpython. I have a copy of this book at my desk for the few cases when I need to debug GIL or memory allocator related issues in cpython. I'd actually recommend learning a higher-level language, like Common Lisp, to better understand Python: knowing about the relevant algorithms and how they transfer should do far more to educate you than learning C, which shares no abstractions with Python. Think about how many fundamental Linux programs are still done in C. Yes. 100%. Knowing C well helps you in any higher level language. In your mind you’ll be able to think what is really happening under the abstraction that is python. (Or ruby or Java etc) Not to understand Python. BUT if you need to write high performance code, it helps a lot. here is a way knowing c can help you become a better "python" programmer: write a library that is much faster in c than in python (allways the case). then create a python wrapper around it and make it a python library. something like this happens with all numerical libraries in python besides that, knowing other languages will help you become a better programmer in general. usual classic advice is learn c, lisp, and ml however you still need to know good programming practices, data structures, and algorithms. with the exception of the first, these are not language specific I learned C after learning Python. It broadened my horizon, I grew dissatisfied with Python and now work in C++ and Go. So it was worth it, though not in the sense that you have probably intended. absolutely not. you might be able to grep cpython source more intelligently, but it won't help you at all with the semantics of the python language itself (versus its dominant implementation), and might hurt. Learning Python’s dis and inspect modules would be more valuable first IMO. Then ctypes then cython. All seem more useful to me than just C from a python programmer perspective. Generally learning X to be a better programmer in Y works for any X and Y languages. There's always something that you can learn and transfer to your daily language. I think it will make you appreciate how much Python does for you, and (particularly if you try to do anything large) how many more bug-types are possible in C. LOL I learned C before Python even existed Really the op should ask if learning c will make him better at leetcode. That’s really the metric all programming salaries are judged by it seems The best is both. And learning c++ python bindings