![Carberra](/img/default-banner.jpg)
- Видео 406
- Просмотров 2 281 582
Carberra
Великобритания
Добавлен 13 июл 2019
Welcome to Carberra!
Regardless of whether you're a budding programmer looking to make your idea a reality, or an avid computer user expanding your knowledge base, this is the place for you. I mainly focus on the world of Python, but occasionally stroll outside the Pythonosphere when I feel like getting a little CrAzY.
When I started this channel, I was in my second year of my Computer Science degree. I have since graduated with a Master's, and now make content for those hoping to traverse a similar path!
Below is a series of links to other places you can find me. I hope to see you around somewhere!
Regardless of whether you're a budding programmer looking to make your idea a reality, or an avid computer user expanding your knowledge base, this is the place for you. I mainly focus on the world of Python, but occasionally stroll outside the Pythonosphere when I feel like getting a little CrAzY.
When I started this channel, I was in my second year of my Computer Science degree. I have since graduated with a Master's, and now make content for those hoping to traverse a similar path!
Below is a series of links to other places you can find me. I hope to see you around somewhere!
5 SIMPLE Pytest tricks to improve your tests
In production code, the tests are often as important as the code, if not more. Without proper testing, how will you know if your code will ever work in the wild? In this video, I share five top tips to improve your tests and to make sure they're working properly!
00:00 - Intro
00:41 - Context [1]
01:33 - Parametrization [2]
03:22 - Finding edge cases w/ Hypothesis [3]
05:41 - Tracking coverage w/ pytest-cov [4]
08:17 - Reducing inter-test dependencies w/ pytest-randomly [5]
10:55 - Parallel testing w/ pytest-xdist [6-7]
13:45 - Outro
[1] github.com/Carberra/perfect-python/tree/main/2404-pytest-tricks
[2] docs.pytest.org/en/stable/example/parametrize.html
[3] hypothesis.works
[4] pytest-cov.readthedoc...
00:00 - Intro
00:41 - Context [1]
01:33 - Parametrization [2]
03:22 - Finding edge cases w/ Hypothesis [3]
05:41 - Tracking coverage w/ pytest-cov [4]
08:17 - Reducing inter-test dependencies w/ pytest-randomly [5]
10:55 - Parallel testing w/ pytest-xdist [6-7]
13:45 - Outro
[1] github.com/Carberra/perfect-python/tree/main/2404-pytest-tricks
[2] docs.pytest.org/en/stable/example/parametrize.html
[3] hypothesis.works
[4] pytest-cov.readthedoc...
Просмотров: 1 861
Видео
Numba makes your code FASTER with ONE decorator
Просмотров 3,7 тыс.День назад
Try Keeper Password Manager free for 30 days, then get 30% off when you upgrade using the code CARBERRA30: www.keepersecurity.com/personal.html - There has been plenty of discussion around Python's new JIT since it dropped, but did you know there are other ways of getting a JIT into Python? One of the simpler ways is by using Numba, which allows you to JIT functions by using a single decorator!...
I baked the Hello World cake (but everything went wrong)
Просмотров 46614 дней назад
It's the channel's 5th birthday, so I thought I'd bake a birthday cake (complete with chocolate sauce)! This isn't just any cake though it's the Hello World cake written in the Chef programming language. In this video we answer the most important question: "How does it taste?!". Chef language specification: www.dangermouse.net/esoteric/chef.html Mike Worth's blog post (Web Archive): web.archive...
Liked Pydantic? You'll LOVE Msgspec
Просмотров 11 тыс.21 день назад
If you've ever needed to work with JSON, TOML, YAML, MessagePack, or even structured data, you'll know how many tools are out there. But what if I told you there was one tool that could do all of those things, complete with a consistent API and with speed as a focus? Well, have I got the treat for you! 00:00 - Intro 00:55 - Working with JSON, TOML, YAML, and MessagePack data [1] 05:38 - Seriali...
Pydantic is OP, here's why
Просмотров 22 тыс.28 дней назад
I've made a video on Pydantic already, but version 2 has since been released, so I thought I would come back to it! You can think of Pydantic as a supercharged dataclasses, with all sorts of functionality even attrs doesn't have. It's great for APIs too! 00:00 - Intro 00:44 - Installing Pydantic [1] 01:12 - Creating models [2] 04:15 - Validating inputs [3] 08:10 - Using Pydantic with an API [4-...
Will Python SKIP these versions?
Просмотров 3,6 тыс.Месяц назад
Sign up to Codecrafters for free, and get 40% off ANY plan when you upgrade! app.codecrafters.io/join?via=parafoxia - Ever since the first public release in 1989, Python has used it's own special flavour of SemVer, but is it now looking to switch to something else? In this video, we look at proposals that might make CalVer for Python a reality. PEP 2026: peps.python.org/pep-2026/ - If you want ...
Partial functions in Python are SUPER NEAT
Просмотров 4,4 тыс.Месяц назад
Partial functions in Python are SUPER NEAT
SIMPLIFY your code with decorators (+ typing)
Просмотров 3,8 тыс.2 месяца назад
SIMPLIFY your code with decorators ( typing)
Implementing OAuth 2.0 from SCRATCH
Просмотров 1,7 тыс.2 месяца назад
Implementing OAuth 2.0 from SCRATCH
I tried a FREE Copilot alternative
Просмотров 2,3 тыс.2 месяца назад
I tried a FREE Copilot alternative
HYBRID callables in Python?! - Jankfest
Просмотров 1,7 тыс.3 месяца назад
HYBRID callables in Python?! - Jankfest
Using Redis/Redict/Valkey in Python (2024 tutorial)
Просмотров 1,9 тыс.3 месяца назад
Using Redis/Redict/Valkey in Python (2024 tutorial)
My Visual Studio Code setup! (2024)
Просмотров 2,3 тыс.3 месяца назад
My Visual Studio Code setup! (2024)
Wait, you CAN use braces with Python?!
Просмотров 3,3 тыс.3 месяца назад
Wait, you CAN use braces with Python?!
The history of Visual Studio Code's WORST theme
Просмотров 47 тыс.3 месяца назад
The history of Visual Studio Code's WORST theme
Is Python 4 ON THE WAY?! (April Fools)
Просмотров 3,2 тыс.3 месяца назад
Is Python 4 ON THE WAY?! (April Fools)
Creating, renaming, and deleting branches - Git Good
Просмотров 4424 месяца назад
Creating, renaming, and deleting branches - Git Good
Ignoring files with .gitignore - Git Good
Просмотров 5184 месяца назад
Ignoring files with .gitignore - Git Good
Create an API in 20 MINUTES with FastAPI (2024 tutorial)
Просмотров 1,9 тыс.4 месяца назад
Create an API in 20 MINUTES with FastAPI (2024 tutorial)
Pushing to and pulling from the remote - Git Good
Просмотров 4794 месяца назад
Pushing to and pulling from the remote - Git Good
Staging and committing changes - Git Good
Просмотров 6164 месяца назад
Staging and committing changes - Git Good
Creating virtual environments in Python (works with Python 3.12)
Просмотров 2,6 тыс.4 месяца назад
Creating virtual environments in Python (works with Python 3.12)
I'd guess if you have a significant conftest setup that xdist would also slow down significantly, since it needs to run conftest for each process
GREAT video with super useful tips; thank you!
You're welcome! 😄
2 things that could have been mentioned: - pytest --cov=my_package --cov-report=html : it outputs an html file which color codes coverage and is quite nice visual representation of cov - might not be strictly pytest related, but configuring the testing extension in VS Code enables the tests to be run individually by just clicking on the green "play" button to the left of the functions (next to line numbers), which is super nice, especially when you are writing the test and don't know if it will work, you can just click that button over and over again instead of going to terminal and starting the whole unit test session with the commands.
Oooo that HTML report type sounds cool, might have to give that a shot when I get the chance.
2:31: one question: does the test cover the free space between the bananas? 😉You test everytime against your own assumptions... not against the universe.
The comment of a true tester!
When I write pytest tests I try to pull as much setup/teardown code as possible out into fixtures so the tests themselves don't get obscured by loads of setup/teardown. One slightly sneaky trick is using fixtures to set defaults for other fixtures and overriding them with parametrize. So maybe I have a fixture 'user' that creates a user object used by lots of the tests and that fixture takes another fixture 'permissions'. Most of the tests expect a default set of permissions maybe 'read-only' so the permissions fixture sets up that default. Then tests that need a different set of permissions in the user object use `@pytest.mark.parametrize("permissions", [("read-write",)]` and pull in the `user` fixture with elevated permissions (you don't have to reference the overridden fixture directly in the test, pytest will complain if you parametrize a fixture that isn't used by the test but it's fine if it is only used indirectly). That works well if you only need to override the default in one or two places: if you need to do it more often then you wrap the relevant tests in a class and either redefine the fixture inside the class or use parametrize on the entire class or use multiple files with the defaults in conftest.py and override them as needed in individual files.
This is awesome haha, congratulations on 5 years mate!
Thanks my guy! Glad you enjoyed it!
What vsc theme is this? Looks nice
Link to a video is in the description.
@@Carberra Thank you!
Just use Taichi.
i tried Pylance, mypy and pylint. But the Ruff the best what i used
Ooh, not sure yet but we use some matrix multiplication functions at work to optimize insurance policies. I bet there's at least a few places numba could significantly speed things up! Right now some larger scenarios with larger input sets take multiple MINUTES to run, if some of those could be brought down to seconds it would not only make our web application more user friendly, it will save a bunch of money in Google cloud function costs. I'll have to do some experimentation and see if they're willing to pay me for the improvements haha!
I hope you get the results you're hoping for! Let me know!
Better way to do this: numbers = [1,2,3,4,5] total = sum(numbers)
I used numba on my Mandlebrot code - 45x times speedup per core for a total of 180x speedup
Holy cow, that's insane!
"source.organizeImports": true gives error, saying it expects string
Change it to: "explicit".
*Sometimes 😂 Thank you, dude😊
have you heard about sum?
you are a great lad
Simple and good, thanks!
While it’s neat, it was removed from the builtins in python 3 because it’s not very performant, and not that readable (therefore not very pythonic). This example you’ve written is proof of that, because you could just call sum on the list.
That was a great explanation. I can see that this a private repo. Could you please share the source code in a public repo.Thanks..!!
This description is wildly confusing. It would be better to discuss the third optional parameter which is the `initializer` which defaults to the first value of the iterable
If you use sum it is not so much ease?
"So many functions are under this hood" should be the title. I think you made a typo.
he didn't though. In fact, it was YOU who made a typo. You said "under this hood" rather than "this under the hood". That is, unless the title changed.
this isnt quite how filter would realistically should used, its if you're going to loop through something and want to filter your iterator to avoid some logic inside your loop, this is exactly where list comprehensions is supposed to be used though, apples to oranges cprofile is a good thing to use for actually finding speed issues as it sees which functions is adding time to your program, this is just benchmarking (which should include variable length lists)
Hey. For benchmarking in python, I highly recommend the Foss project pyquickbench
Thanks for explaining with the application along with the Syntax 🙂
Thanks for the video. Why do you use the minimum instad of the mean or median to compare both approaches?
Averaging the results would include those outliers, making the test results less accurate (unless of course you did some work to remove outliers, then an average would be more accurate). It's mainly done to get rid of any variance that may be caused by the first run -- I've seen it before where the fastest time out of two tests was always the one that ran second, irrespective of the code, due to startup shenanigans.
@@Carberra Using the “min” value could also be an outlier no? In a real example, you’d almost certainly want to do a statistical test (e.g. using scipy.stats.ttest_ind) to analyze if one implementation was faster. Even then there are other variables to consider, but generally speaking it would provide a reasonable analysis of the two approaches
@@Carberrathen you should use median and not min what is the logic here??
Thank you 😊
If you do it again you might try creaming your butter and sugar together first. Then the dry and liquid ingredients get mixed separately before combined. The cream doesn't have to be hot before going into the tempered chocolate if you add it in very slowly and mix the whole time you are adding it. If you have too much egg I would mix it first before pouring any out so it's homogeneous first. - source: guy who watches a lot of cooking shows but never bakes himself
Thanks for the tips my guy! Baking is certainly not something I do often so don't have too much knowledge (though my mum is very good with it), but certainly isn't something I dislike, so perhaps I should do more. There's a _chance_ doing my first baking in years while also trying to record it perhaps was never gonna go perfectly 😅 Though added to the chaos, so worth it!
@@Carberra was certainly fun to watch and it looked like you had fun doing it. That's all that really matters
Yeah it was! I always have fun doing these special videos, and I even got a cake out of this one! I'm glad you enjoyed it too 😄
You can measure liquids more accurately using the scales. Density of double cream is apparently about 1.01g/ml so 54ml would be 54.5g. Beaten eggs have a density between 1.03g/ml and 1.1 (weight required left as an exercise for the reader). Nice little Denby bowl btw, we have a full set of those and it's the first time I've seen anyone else with that design.
Yeah I thinking about that, but didn't really know how plausible that would be. I had no idea double cream was basically 1:1 though, that would've definitely been easier! Denby bowl (and the rest of the Denby -- I believe the collection is called Memories) is my mum's and she absolutely adores it. We have a full set as well! You can actually still get them, albeit second hand -- we did that recently cos we needed a few more plates. Not too expensive either, considering it's Denby anyways.
@@Carberra Tell your mum she has impeccable taste.
thank u so much mate, really helped me out
Does it include Michaelmas?
So this is a tradition now right? I will mark my calendar 🎉
Congrats Carberra! Keep up the good work!
A short worth while saving🎉
Congrats on reaching 5 years, here's to another 5 more!
Cheers man!
Happy birthday!
Thank you!