Awesome vid, as usual! There's not much out there on the C-API that is this straightforward. I recently wrote my first C-extension with a lot of frustration (I hated C before starting), but I now have an appreciation for it. I got a ~20% speed-up vs the same function implemented in vanilla Python. I'm curious to see how it stacks up against Cython, but I have no idea how to write .pyx
This is, most of the time, more of a hobby/curiosity than an actual need (which is still great so many thanks). However, it's usually best to check out libraries like numpy/scipy/numba/etc before writing your own C extension.
@@anthonywritescode Perhaps I did not explain myself correctly. I meant to say check it's best to check numpy (or other C based libraries) first than trying to implement the same code. I also don't quite follow the hassle of installing numpy. I never had any trouble with it 🤔 Anyway, thanks for the video. I wanted to learn exactly what you demoed so I'm grateful for it 😊
im starting new job as software engineer and they are going to use capi for python 2.7. I find this video so useful. Thanks man! PS. What you like to continue with this topic? ;)
whew 2.7 that's rough! glad this was helpful -- there's some other related things to check out if you don't want to write as much C: th-cam.com/video/X5irxO5VCHw/w-d-xo.html
the python bits have to be `extern "C"` at the least so integrating c++ is kind of tricky. there isn't really much upside other than c++ is a different language than C
the code samples are all up on github.com/anthonywritescode/explains I can't really go any larger on font size (it's already extremely large) -- I'd recommend *not* watching on a phone
thank you, that was exactly what i was looking for!
Awesome vid, as usual! There's not much out there on the C-API that is this straightforward.
I recently wrote my first C-extension with a lot of frustration (I hated C before starting), but I now have an appreciation for it. I got a ~20% speed-up vs the same function implemented in vanilla Python. I'm curious to see how it stacks up against Cython, but I have no idea how to write .pyx
20% or 20x? later is more probably, c is the fastest, python is the slowest in runtime, If use numpy, or similar, you use c, just from python call.
What this enviroment/WM? I search for usable tiling solution...
it's my own! I call it the "anthony window manager"
Does sys.getrefcount(ANY STRING) by default return 3?
Because it didn't change after the code rewrite.
Like watching your vids. Even thou I am still to grasping the core concepts of python language itself.
This is a nice video, it was a good watch and to the point.
Thanks for the video! Why we dont have to call Py_DECREF on name variable?
PyArg_ParseTuple I believe gives borrowed references, so unless you're doing something with that object it doesn't need an increment or a decrement
This is, most of the time, more of a hobby/curiosity than an actual need (which is still great so many thanks).
However, it's usually best to check out libraries like numpy/scipy/numba/etc before writing your own C extension.
this is terrible advice -- numpy does not help you interface with C libraries and is a behemoth of a dependency to pull in
@@anthonywritescode Perhaps I did not explain myself correctly. I meant to say check it's best to check numpy (or other C based libraries) first than trying to implement the same code.
I also don't quite follow the hassle of installing numpy. I never had any trouble with it 🤔
Anyway, thanks for the video. I wanted to learn exactly what you demoed so I'm grateful for it 😊
@@anibaldk I think you either dont quiet understand either what numba does or what the c api is for 😂😂
im starting new job as software engineer and they are going to use capi for python 2.7. I find this video so useful. Thanks man! PS. What you like to continue with this topic? ;)
whew 2.7 that's rough! glad this was helpful -- there's some other related things to check out if you don't want to write as much C: th-cam.com/video/X5irxO5VCHw/w-d-xo.html
Great video. A Zig version would also be nice.
same for RUST and GO as mentioned please ;)
Is there any advantage of using C++ over C for this and if so can you make a guide?
the python bits have to be `extern "C"` at the least so integrating c++ is kind of tricky. there isn't really much upside other than c++ is a different language than C
@@anthonywritescode thank you
"there isn't really much of an upside other than the downside"@@anthonywritescode
Why we use .c extension to save program
the whole point of this video is to demo a C extension
what does 'pip install .' do?
it installs the source package at `.` (the current directory)
@@anthonywritescode thanks a lot! it helps!
Thanks sir
How to decompile .so file?
in the general case you cannot -- you can "disassemble" it (to assembly code) -- but getting it back to the original high-level language is impossible
@@anthonywritescode ok bro,but....
Too small font, can't see the code. A pity :-/
the code samples are all up on github.com/anthonywritescode/explains
I can't really go any larger on font size (it's already extremely large) -- I'd recommend *not* watching on a phone
@@anthonywritescode Awesome, thank you!