- 27
- 98 340
The Code Guy
United Kingdom
เข้าร่วมเมื่อ 14 ธ.ค. 2020
I have been a professional Developer for over 25 years, with experience building complex systems in multiple technologies.
This channel is to share my knowledge and experiences with you.
I hope you find it useful and enjoy
This channel is to share my knowledge and experiences with you.
I hope you find it useful and enjoy
Python Zip Function Unzipped: Master Data Pairing in Seconds!
Dive into the powerful world of Python with my latest tutorial! In this video, we unravel the secrets of the Python zip function and show you how to master data pairing in seconds. Whether you're a beginner or an experienced coder, you'll find this tutorial packed with valuable insights and practical examples.
Join me as I walk you through:
What the zip function is and how it works
Real-world examples of using zip for data manipulation
This video is perfect for anyone looking to improve their data handling skills and streamline their Python code. Don't forget to like, comment, and subscribe for more coding tutorials and tips!
Do you need thumbnails? Get in touch with my artist here:
TrueRedTFox
Stock Footage and sound effects: - (Referral link)
ArtlistIO : artlist.io/Guy-1799812
Join me as I walk you through:
What the zip function is and how it works
Real-world examples of using zip for data manipulation
This video is perfect for anyone looking to improve their data handling skills and streamline their Python code. Don't forget to like, comment, and subscribe for more coding tutorials and tips!
Do you need thumbnails? Get in touch with my artist here:
TrueRedTFox
Stock Footage and sound effects: - (Referral link)
ArtlistIO : artlist.io/Guy-1799812
มุมมอง: 183
วีดีโอ
Numba vs C: Python's JIT Compilation is insanely fast
มุมมอง 1.4Kหลายเดือนก่อน
Discover how Numba, Python's JIT compilation library, unlocks incredible speeds, even outpacing C in some cases! In this video, we'll explore: 🔹The basics of Numba and JIT compilation. 🔹Head-to-head performance comparisons between Numba and C. 🔹Real-world applications where Numba can give you a significant speed boost. Whether you're a seasoned developer or just curious about Python's capabilit...
Install Your Own Python Packages Using pip - The easy way!
มุมมอง 1862 หลายเดือนก่อน
Ever wished you could easily install your custom Python packages with just a single command? Look no further! In this video, we’ll break down the entire process of converting Python packages into pip-friendly tarzip files. Say goodbye to all the hassle and hello to simplicity. Follow along for step-by-step instructions and unlock the magic of “pip install” with your own creations. This guide is...
Just how Slow is Python?
มุมมอง 51K2 หลายเดือนก่อน
In this video, I dive into the speed differences between Python and C . I write and compare the same program in both languages, revealing why C outperforms Python. Despite its performance drawbacks, Python remains incredibly popular. I explain the reasons behind its continued success and share practical tips to enhance Python's speed using better coding practices. Tune in to learn more and boos...
Become a Lord of TIME in Python
มุมมอง 4184 หลายเดือนก่อน
Unlock the secrets of time manipulation in Python with my latest tutorial! In this video, you’ll master the time module and learn how to: 🔹Learn how the time module deals with time. 🔹Convert between different time formats effortlessly. 🔹Measure code performance with precision. 🔹Implement delays and pauses in your scripts. Whether you’re a beginner or an experienced developer, this tutorial will...
Code Tic-Tac-Toe in Python with an Unbeatable AI
มุมมอง 6435 หลายเดือนก่อน
Put all the Python skills you’ve learned to the test as we code Tic-Tac-Toe from scratch. We’ll then implement an unbeatable AI using the minimax algorithm, a powerful recursive AI technique. Code along with me on this Python project to test and improve your skills. We’ll test the AI by having it play against itself over 10,000 games and analyze the results! Do you need thumbnails? Get in touch...
Python Logging Explained: Levels, Handlers, and Formatters
มุมมอง 4605 หลายเดือนก่อน
Unlock the power of Python logging with our comprehensive guide! 📊 In this video, we dive deep into the essentials of Python logging, covering: 🔹Logging Levels: Understand the different logging levels and their significance. 🔹Handlers: Learn how to direct your log messages to various destinations. 🔹Formatters: Discover how to format your log messages for better readability. Whether you’re a beg...
Python’s Main Mystery: Demystifying if __name__ == '__main__':
มุมมอง 1.3K6 หลายเดือนก่อน
Unlock the secrets of Python's execution model with "Python’s Main Mystery: Demystifying if name ' main ':". This comprehensive guide peels back the layers of Python's `if name " main "` statement, providing you with the knowledge to write modular and scalable code. Whether you're a beginner looking to understand the basics or an experienced developer aiming to refine your Python skills, this v...
Master Regular Expressions in Python: Unleash Hidden Patterns!
มุมมอง 6246 หลายเดือนก่อน
Unlock the Power of Regular Expressions in Python! 🚀 Dive into practical examples and learn how to wield regex like a pro. From searching and extracting text patterns to advanced manipulation, this hands-on tutorial will supercharge your Python skills. No theory, just code! In this video, you’ll master essential regex techniques, including: 🔹Compiling: Understand how to create regex objects eff...
Regular expressions - Easier than they look!
มุมมอง 2.7K6 หลายเดือนก่อน
Are you intimidated by the complex patterns of regular expressions (REGEX)? Fear not! In this video we’ll unravel the mysteries of REGEX and show you how simple they can be. Whether you’re a beginner or just looking to brush up on your skills this guide is for you. Regex is supported in all major programming languages including Python, C#, Java and Java Script to name a few. What You’ll Learn: ...
Rounding numbers in Python - Don't get this wrong!
มุมมอง 2087 หลายเดือนก่อน
Rounding numbers in python not working as expected? Discover the nuances of rounding numbers in Python with our latest tutorial. While rounding might seem straightforward, Python's built-in methods can lead to unexpected results. This video demystifies the process, offering insights into Python's `round()` function and how to implement the 'round half up' method like a pro. Perfect for beginner...
Python JSON Mastery: From Strings to Services
มุมมอง 2.5K7 หลายเดือนก่อน
Unlock the power of Python and JSON in this comprehensive guide. Learn to parse JSON strings, read and write JSON files, and connect to JSON-based services seamlessly. Perfect for beginners eager to master data handling in Python. 🔍 What You'll Learn: 🔹Basics of JSON: Understand what JSON is and why it’s a preferred format for data interchange. 🔹Parsing JSON Strings: Learn how to convert JSON s...
Python Type Annotations: Code Clarity Unleashed!
มุมมอง 1.3K7 หลายเดือนก่อน
Unlock the power of clear Python code with type annotations (type hints)! In this beginner-friendly tutorial, I'll guide you through the game-changing benefits of using type annotations in your code. 🐍✨ 🔍 What You'll Learn: - The basics of type annotations and how they can improve your coding experience. - Step-by-step instructions on how to implement type annotations in Python. - Best practice...
Python Sets - Everything You Need to Know
มุมมอง 7237 หลายเดือนก่อน
Unlock the Power of Python Sets: A Comprehensive Guide for All Skill Levels. Whether you’re just starting your Python journey or you’re an experienced coder, this video is for you! Join us as we explore Python’s versatile Set data type, covering everything from the basics to advanced techniques. 🔍 What You’ll Learn: 🔹Introduction to Sets: Understand the fundamentals of Sets and their role in Py...
List and Dictionary Comprehension in Python - Level Up your Code!
มุมมอง 1.5K8 หลายเดือนก่อน
Elevate Your Python Skills: List and Dictionary Comprehension Mastery Unlock the full potential of Python with our comprehensive guide to list and dictionary comprehension. These powerful features will revolutionize the way you write code, making it faster, cleaner, and more efficient. Ideal for beginners and intermediate coders alike! 🔑 Key Takeaways: 🔹Understand the simplicity and power of li...
Faker 101: Generate Realistic Bulk Data in Python
มุมมอง 3659 หลายเดือนก่อน
Faker 101: Generate Realistic Bulk Data in Python
How to Make Your Python Code More Modular and Reusable
มุมมอง 18K9 หลายเดือนก่อน
How to Make Your Python Code More Modular and Reusable
Working with Files in Python | Create, Update, Delete, Rename etc.
มุมมอง 3K9 หลายเดือนก่อน
Working with Files in Python | Create, Update, Delete, Rename etc.
Python Essentials: Dive Deep into Lists and Tuples
มุมมอง 88011 หลายเดือนก่อน
Python Essentials: Dive Deep into Lists and Tuples
Functions - The basics of re-usable code in Python
มุมมอง 453ปีที่แล้ว
Functions - The basics of re-usable code in Python
Python Essentials: While Loops and If Statements
มุมมอง 245ปีที่แล้ว
Python Essentials: While Loops and If Statements
Python Basics: Variables and Types Explained
มุมมอง 442ปีที่แล้ว
Python Basics: Variables and Types Explained
Getting started with Python - Installing the tools for success!
มุมมอง 655ปีที่แล้ว
Getting started with Python - Installing the tools for success!
Sure, you create the prototype in Python, then rewrite it in C if needed. Porting Python code is rather easy once the initial design is done. CPython extensions can become messy though. Even if you get the code to work, it's hard to eliminate all memory leaks during the interaction with Python because you're relying on Python's garbage collector to free the memory. Not even popular libraries like TensorFlow seem to get that right.
If you concern about Python speed just simply use Numpy , Pandas like libraries. 😂😂😂
Awesome!!!!
Glad you liked it. Thanks for watching!
what language would you say comes closest to c and c++ compile/run speeds, while still being secure, memory-wise? ive heard that rust it the togo for this, but idk much about rust. wanted to go with c++ and just get good with memory, but at the same time meh cuz White House rly wants us to go with safer languages
Rust I think was deifiantelty in second place. I think golang can also be pretty fast, though not used it myself.
Production speed is where python is much faster than C++ and many other languages. This extra speed you're talking about is largely not needed MOST of the time. Your bottlenecks are almost never CPU these days. Being able to create a functional MVP in 1/10th the time is a huge deal. It's something college freshmen don't understand because they have no real world experience.
Someone I can agree with wholehartedly. Thanks for sharing your thoughts and for watching!
So basically 11 times worse code, but can be written by lazier or stupider developer.
11 times slower not worse. Aren't all developers lazy, know I am. Stupid, I diagree, you have a tonne of packages at your fingertips to write what you need way faster. Thanks for watching!
Python is good for prototyping. It should stay as prototyping. Note: I like Python. I still feel it's misused.
For me It definately has a place in production for some tasks. Thanks for sharing and watching!
Simple syntax, no memory management, you don’t have to do anything
If you had more practice and developed in C++ on a regular basis you could've written it significantly faster. In fact, I'd argue that C++ is one of the fastest to write languages for common things. You can simply give everything an auto type and it's just as loosey goosey as Python.
There is still a lot more to think about because of the low level nature, but I agree, would definately get faster if I worked in it often enough. Thanks for watching ans sharing your thoughts.
Development speed? If you want development speed use to-basic. I can get a simpler program out in a few minutes. Once you learn it you will have virtually no bugs
I'm not familiar with that? Thanks for watching!
answer: yes
You can make it fast in many ways though.
I code in C++ and never used cmake or json files.
Even for big p[rojects? Yes I probably could have just written a batch file to call the compiler directly for this small example.
As a C student in Uni I now learn Java and it hurts so Python is not for me
Java is evil though!
Subset of Python, not normal Python…
Indeed - Thanks for watching and making that point clear!
The time you’re measuring around the 3:10 mark is the time it takes to declare the function, not the first run time or the jit.
I'm, guessing the time jump with njit then is just the interpreter parsing the decorator code. Did seem odd for the jit to happen there. Thanks for thew correction and for watching!
This is just Julia now.
Not tried Julia, but from what I understandm, see the simularity. Thanks for watching!
i started playing with code using c++, i never had any formal education, just articles, forums and youtube. then one day i decided to make a game in python. i never once felt like python was any easier or faster to write, maybe it was because i was learning along the way but i feel like it would have taken me just as long to learn how to make it in C++
I started out with pascel then moved quickly to C#. I havn't found a language quicker to code than Python. Also self tought. But my c/c++ has always been only when I need it kind of thing. I wonder if I'd started out with c++, I would have had a similar experience. Thanks for wstching and sharing your storie!
@@the_code_guywould love to see the same comparison with c#
Classes are not slower than straight C code. Virtual method calls are slow, but if you don't do that, there shouldn't be a difference. Internally, classes are structs and methods are functions taking an implicit "this" pointer as a parameter. A non virtual method call is the same as calling a function in C and it is neither slower nor faster. A virtual call is like calling a function through a function pointer, which adds a level of indirection and the slowdown can be significant in inner loops.
Thanks for the detaild correction and for watching!
i prefer lua :) i know nothing about coding, im just a basic linux user and out of the box i can use lua, other languages i can see how its written but it still somehow always gives me errors, so thats where i know whats good for me.
I have heard a lot of good things about lua in the comments for this video. Going to have to give it a try! Thanks for watching and your thoughts.
With Python you can get more people, fire them and get new ones - whenever you need, because of low entry level and high code production speed. With C you have to valuate your employees - which is always hurt the "business".
I think it will probably depend of the complexity of the products. But Python developers will definatly be easier to hire en masse.
As a python developer, i would add that anyone who develop in python for exec speed is a fool. But when developing a product, development speed is king : developing a product in 2 weeks -> ship it -> get customer complain that it's too slow -> rebuild it is far superior than : developing a product in 8 weeks -> ship it -> get 0 customer complains (but lost 6 weeks of revenue)
Don't let the "bu- but! Python is slow!! 😡 You can't use python in leetcode contests! 🤬" squad see this. They don't know how real world business moves
Now try GO
It is on my list of langauages to pick up. Thanks for watching!
12 hours to code a tictactoe script is crazy. Calls himself "the code guy"
I said I was rusty... Thanks for watching!
@@the_code_guy You said that you could've shaved a third of the time, so 8 hours minimum ? 8 hours is fucking crazy ! If you can't code tictactoe in less than 2 hours (2h is generous), I don't really think you can code. If you're new to programming, that's fine, but calling yourself the code guy is kinda ironic lol.
I think the biggest difference is Python is so much easier to learn than c++. Companies would rather hire someone with 1 year of experience in Python over someone with 1 year of c++ experience.
Indeed. Thanks for watching!
If you know you can use JIT and packages that are in C anyways in the background. You can completely bypass the performance penalty. I'm surprised that you didn't do a performance run with pipy and cython since you specifically mentioned them. Instead of just keeping the 10x slower comparison from the start... You wouldn't even need to edit your code with them.
I wanted to the keep the video informational and non-technical - I do have plans to make dedicated videos to each metrhod of speeding up code with the pro's and cons. Thanks for watching asnd sharing!
@the_code_guy yeah I get the vibe. But i think they would have been good information markers without getting in the weeds of the limitations they have. I don't think you should rewrite the code to maximize numpy use and pure C libraries or what ever crazy optimizations. Just with 0 changes what performance can you actually hit.
Don't forget the conda extension "numba" -- a just in time compiler that needs no changes or any other modifications to your python code. It is very fast. Also remember that the numpy library is very fast.
I actually started playing with that for the first time this week. It's crazy! Thanks for sharing and for watching!
Thanks for the note and for watching!
@@the_code_guy keep playing with python! there are ways to speed it up, but realize that the reason it is slow is for ease of use and compatibility. For quickly creating something python is fast but slower at execution. if you control the environment and can use it for longer then setting it up with numba, conda and even considering libraries that are not part of the core python project such as numpy, and other specialized libraries. you can also take a closer look at multithreading or sometimes async for outputting to terminals. it will finish way faster and waste less time in idle for the terminal to take/give input/output from the program. Use multiprocessing only when you can queue up tasks for processing multiple things in parallel!
I've heard that if you use Python on large data sets, using a decent JIT compiler, it can actually perform pretty well. Maybe not as fast as equivalent C++ code, but it can close the gap a bit. I think the reason is it can keep optimising the machine code because the same code is running so many times. I'm primarily a C++ developer, so I don't really know how true that is though.
It is true. I've been playing with a new lib this week that got a python function to c speed. Thanks for watching and sharing!
Crash? Why would I use a variable to represent a number, then change it to represent a string? Who does this?
Mostly by accident one would hope, but I have seen juniars do this kind of thing. Thanks for watching!
With that comparison, now remove console output each game
It's around 3 times faster with no output. Thanks for watching!
Can you please try the various ways to compile Python and show how fast is each? Would any of them be similar to C/C++ performance?
I intend to make a couple of videos for the varius ways to make python faster and show the perfortmance. Thanks for watching!
You don't "iterate over array" with indexes in C++. That's C.
Not true lol. It's just a convenience thing. Good luck iterating over 2d matrix, or with anything but stride of 1. Unless you absolutely want to ruin performance by creating vector of vectors ofc.
@panjak323 I don't see any issues with matrices. Use ranges and iterators for any type of collection. They compile to the same machine code as indices but are less error prone.
I am a little on the old school side of things when I code. Haven't actually tried a lot of the C++ constructs, but sounds like they will help solve the debugging problems I had. Thanks for watching!
Yes, I looked at vectors and decided no.
@@the_code_guy the array equivalent is not vector, it is std::array
Please also do with c
May give that a try but no promises. Thanks for watching!
I program just for fun and no one is further away from a professional than me. Nevertheless, a programming language that doesn't need a variable declaration scares me and is a little weird
It's not actually too bad once you get used to it. I do wish there was an option to properly type though. Thanks for watching!
Huh? Wouldn't the c++ be less than 200 lines? Most of them being { and }
There weren't quite that many brackets. Thanks for watching!
one thing is the printing which obviously is a bottleneck, but did you compile c++ with optimized build O2 or O3 flag? I expect 10000 games of tic tac toe to finish way faster than in your example
I just did it in release mode which I believe on the windows compiler uses /O2
windows console printing just sucks
If whatever you're producing will do the job in 100 ms when its coded in python instead of 10 ms if it were to be coded in C++ it doesn't matter at all to the user who doesn't know this fact. Btw the reaction time of the best people around is around 100 ms and realistically it can even take multiple seconds before anyone who isn't an annoying nerd like we are will complain
Very true. Thanks for watching!
Write your code in python then ask chatgpt to convert it to c++ 😅
😂Thanks for watching!
Rizz
Glad you liked it!
The great thing about python is that you can use it for the high-level logic, and then move the performance bottlenecks to a lower-level language.
Absolutly. Thanks for watching!
the number ive always heard was 140 times slower
It probalay depends on what the program is doing. Thanks for watching.
People complaining about printing to terminal slowing down the program have probably never build any real applications. Yes, it's a bottleneck. Real applications tend to have those. IO is a very common bottleneck - not just printing to the terminal, but also things like calls to databases or APIs can be very significant bottlenecks that have nothing to do with the language you are using. If you factor those in, you often find that switching to a language that is a bazillion times faster doesn't actually make your application faster - you are just waiting faster. That's why Python is so widely used, despite being relatively slow - because its lack of performance doesn't actually matter so much for many applications.
You make a really good point here. Thanks for sharing and watching!
It depends on your application, bit this is a good point. Especially for web waiting for REST. But under no circumstances would or should one write say, a video game in Python.
Hmm.
Thanks for watching!
i think python was slower mainly because it somehow took you over 200 lines of code to make tic tac toe
Wanted to build it with objects to round out my beginner series, it absolutely could have been shorter, but the Minimax algorithm is by far the slowerst component. Thanks for watching!
Can you redo the measurements this time without printing to the console because that is slowing code so much. In my case printing in C can slow down code up to 200 times in some scenarios.
When I disabled prnting to the console in C++ it was almost 3 x faster, which is insane.
bruh, don't compare a compiled executable to a interpreted script... atleast compile the python code to an .exe before comparing, cause that'd be unfair towards python
I did say it was unfair, but I also talk about how you can improve performance towards the end. I actually program in python and love the language. Thanks for watching!
@@the_code_guy yea i wrote my comment during the tic tac toe demonstration before watching the rest of the video... but i did watch it till the end tho! Pretty great stuff, although you should've also talked about RustPy
About the number of lines: Well, in the c++ code many lines contains only a single "{" and the closing "}" can be placed by many editors automatically. So even if the number of lines is doubled in c++, it doesn't mean that developing is also 2 times slower.
Number of lines was a bad choice on my part. I was struggling to find away of illustrating the develeopment speed difference, in reality it mostly down to how you have to think differently but also I foind c++ much harder to debug. Thanks for watching!
@@the_code_guy In my opinion c++ is much easier to debug. The problem with "default" interpreter Python is, that bugs are many times reported much too late, since they sometimes occurs on runtime only after a lot of time, while with c++ you can catch a lot of bugs just after 1 second, because the compiler complains about that bugs.
Good video. When i saw title, i was thinking like. Oh this is another video of why you should use C++, because it's much faster than python. But hopefully the vid is not about that. For me I use learn and use python because It has many helpful libraries with ready-made solutions, and also bcz it's syntax is very easy, and you can make programs way more faster. In fact many people who speaks about comparing python and C/C++ speed, everyone for some reason forgetting about libraries like ctypes, numpy, etc. This libraries can make python runs at speed that is comparable with C++. So why we should use C/C++ just bcz the speed. It should be used when you need direct access to system components, not only bcz of the speed. Sorry if I offended you.
No offence taken. Didn't expect this to be so controversial. Way to many people hate on python because it's not c++. I use python a lot so this video was pretty well rounded and covered a lot of ways you could speed up python.
Could you please make a comparison between javascript and c++ ?
Node or just client side js? Can't guarantee it but will add to my video ideas list.
Python is a disgrace. It should not exist. If the community had focused on C++ only instead of creating a bunch of other programming languages, we wouldn't be arguing about speed or ease of development.
I think we would also not have web applications. Whist I diagree with you I welcome the debate. Thansk for watching and sharing your thoughts.