Тёмный

Compile Python to C | cython, pypy,numba | python tutorials 

Pythonist
Подписаться 10 тыс.
Просмотров 52 тыс.
50% 1

Опубликовано:

 

6 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 91   
@Pythonist
@Pythonist 4 года назад
Your feedback is truly important to me. So, bombarded me with your quires, questions, and criticism 😎. And, smash the like button 👍
@MichaelMantion
@MichaelMantion 4 года назад
I know its an example but you could never have a tripple where b is a+1. You could seriously optimize your code. to cut out a lot of work.
@Pythonist
@Pythonist 4 года назад
@@MichaelMantion 'c' is also involved......
@FreeMarketSwine
@FreeMarketSwine 4 года назад
I'd like to customize certain classes in the sklearn library. Just looking through the sklearn GitHub, I don't see anything having to do with compilation steps. Do I only need to create new .pyx and .pxd files and reference those files instead of the sklearn files to make it work?
@mauricioalfaro9406
@mauricioalfaro9406 4 года назад
Please put subtitles
@pietraderdetective8953
@pietraderdetective8953 Год назад
great video! can you please kindly give an update regarding the recent Cython 3.0 ? especially the pure python mode which looks very interesting! i am obsessed with speed, but I can only write Python (non-programming background). cheers!
@pietraderdetective8953
@pietraderdetective8953 Год назад
coz the pure python mode enables us with no C knowledge to use Cython and benefits from the speed-up. Am i correct regarding this?
@vsevolodnedora7779
@vsevolodnedora7779 3 года назад
Thank you for the tutorial. It is brief (sadly) and it is very useful. Especially for stubborn people like me, who needs fast scientific code but does not want to learn c++ .
@Pythonist
@Pythonist 3 года назад
Glad it was helpful, stay connected!
@paulpenrod5285
@paulpenrod5285 5 лет назад
Thank you for the tutorial. It has answered a few questions I've been looking at for optimization. By extension, the next two questions are: A) What considerations do I need to take in, when trying to compile a series of progs/libs so that the end result is an executable with minimal fuss, and B) What are your suggestions to apply multi-threading, or multi-processing to address problems that can be broken down into parallel runs? Thanks in advance.
@Pythonist
@Pythonist 5 лет назад
(A): For compiling your code you should consider various things as: 1): Your code tends to be much mathematical 2): Has lots of loops that repeat the same operations many times 3): Make sure you have provided the Type information (B): For Multiprocessing, I will create a detailed video for that. So, be tuned!
@livethumos
@livethumos 3 года назад
Great video! This was an easy to understand overview of the tools we can use to speed up our Python 🐍 code
@oskarpaulsson5885
@oskarpaulsson5885 4 года назад
8:34 If you're doing this on windows heres what you need to write: python setup.py build_ext -i --compiler= I tried doing it with MinGw but I couldn't figure out how to set it up properly and ended up downloading and installing Visual Studio(the visual studio IDE), when using visual studio as your compiler you should write python setup.py build_ext -i --compiler=msvc When installing visual studio, remember to include C++ compatability, otherwise I dont think it will work. Also, on windows you will get et .pyd file, not .so
@Pythonist
@Pythonist 4 года назад
We are using Visual Studio Code editor not the Visual Studio IDE and of course we need to include C++ compatibility.
@ghipsandrew
@ghipsandrew 5 лет назад
Very good and informative video. I've learned about other technologies beside cython and numba
@Pythonist
@Pythonist 5 лет назад
Thank you for your feedback!
@Satyam1010-N
@Satyam1010-N Год назад
Series step by step for professionals in finnace in hft in research in etc it's so good. Thanks.
@HugoCoolDude
@HugoCoolDude 4 года назад
good pacing, never got bored during the video! I would maybe focus a little on your pronunciation, i don't mean to be insensitive to your accent but with a little training you could make it easier for your audience to understand you. You can see where the automatically generated subtitles get confused. best of luck mate! (also, i know this might have been part of the aim of this video, but calculating the stdev using linear algebra would have been a fairer comparison to many data scientists, i would never code the calculation using for loops, instead statisticians would be using numpy matrix products. So now i wonder if what improvement you would have yielded if you used a more optimal formulation to begin with)
@Pythonist
@Pythonist 4 года назад
@HugoCool First of all, thanks for your kind words. You are right mate regarding the accent, I realized it at early stages and try my best to improve this thing, can you take a look at this latest video and provide your valuable feedback? Here’s the video link: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-jx5SlRi28DE.html
@willer2k
@willer2k 3 года назад
awesome squewred explanation!
@Pythonist
@Pythonist 3 года назад
Glad it was helpful!
@Agrover112
@Agrover112 5 лет назад
A complete video on Cython !😍
@Pythonist
@Pythonist 5 лет назад
Sure, Will add it to the queue
@_Amilio_
@_Amilio_ 3 года назад
Great video 👍
@namimontana5710
@namimontana5710 5 лет назад
Thank you for this awesome explanation!
@jesuis_jo
@jesuis_jo 4 года назад
Hey man, this is excellent, thanks for sharing.
@Pythonist
@Pythonist 4 года назад
Thank you for your kind words, stay tuned!
@pratikpawar05
@pratikpawar05 4 года назад
can you plz make a detailed video series on cython were you take some python examples & optimize it using cython. It would be a great serious to watch :)
@Pythonist
@Pythonist 4 года назад
Sure, I'm working on a complete series of Cython, you will get that soon, stay tuned!
@pratikpawar05
@pratikpawar05 4 года назад
@@Pythonist Thank you for accepting my request :) You are soon going to be the best content creator for python.
@ShahidMehmood-pq3co
@ShahidMehmood-pq3co 5 лет назад
Loved the tutorial
@Pythonist
@Pythonist 5 лет назад
Thank you for your feedback!
@mermaidcodes
@mermaidcodes 2 года назад
I never understood why can't we save our code in binary and run it like that after we finished developing ? . The computer compiles our code to make binary any way . Right ? So why can't we save our projects like that after we finished developing it ?
@michalski9141
@michalski9141 2 года назад
not sure what you meant but the file that holds your code, main.py for example contains binary data for the text in your code. a compiled executable contains binary sequences that your processor interpretes as instructions instead
@leonardovillegas7015
@leonardovillegas7015 3 года назад
Before starting and being a Python beginner, should I start learning how to use cython already? Or should I master python first?
@Pythonist
@Pythonist 3 года назад
Python is the core.... Cython is a tool to improve the performance of Python code. As a beginner first master the Python language.
@noyes6758
@noyes6758 3 года назад
I think it depends on the project. I made a somewhat simple web scraper yesterday, and since the web requests slow me down more than optimization, I find no point in cythoning it. On the other hand, I have a project that looks through the machine code of files and tries to analyze what they do, and it is SLOW to the point you might as well just use virustotal and abandon the project
@stefanguiton
@stefanguiton 3 года назад
Great video!
@JaswantSingh-it3vl
@JaswantSingh-it3vl 5 лет назад
Nice..keep doing good work.
@Pythonist
@Pythonist 4 года назад
Thank you for your good words, keep watching and feel free to ask if you have any question about Python.
@hnd13
@hnd13 4 года назад
Thanks a lot☺️ please make a video on cython
@Pythonist
@Pythonist 4 года назад
sure, you will get soon!
@dicember92
@dicember92 3 года назад
Great vid, very clear! A question: is it possibile to use Cython to speed up parts of code that uses esternal libraries?
@Pythonist
@Pythonist 3 года назад
Yes you can!
@bhargav8232
@bhargav8232 4 года назад
Very well made video
@Pythonist
@Pythonist 4 года назад
Glad you liked it
@electricz3045
@electricz3045 4 года назад
What is the best option to compile to C++ to make it faster and better obfuscate the C++ code at the end? Python obfuscation won't work and Pyarmor is only working with small filesizes
@Pythonist
@Pythonist 4 года назад
I think Cython can be a good choice :)
@electricz3045
@electricz3045 4 года назад
@Christian Weissmuller nah I now have bought Pyarmor full version then I made it Clientside obfuscated it and compiled it to a executable then I have customers the exefile that only has the code in it that acess my server and take the right code
@hendripratamabusiness5078
@hendripratamabusiness5078 2 года назад
For decompile python encrypt by c What should i do sir
@GauravSharma-ui4yd
@GauravSharma-ui4yd 3 года назад
Which vscode theme you are using?
@Pythonist
@Pythonist 3 года назад
Synthwave 84
@laylamohammad9272
@laylamohammad9272 Год назад
can i write a fuzzy logic in python and convert it to c using Cython?
@everythingbagel7171
@everythingbagel7171 2 года назад
afaik, shedskin, pythran are Python to C++ converters, but do they also convert Python to C?
@ambeshsingh1251
@ambeshsingh1251 3 года назад
Hi, thanks for the video. I wrote a simple hello world program in python and using your steps I compiled to get a .c and .so file. Now how can I directly compile and run this .c file to print hello world which is written in python def.Please advice, Thanks in advance.
@Pythonist
@Pythonist 3 года назад
To run this you can sue any C compiler like gcc and use the command as: gcc helloWorld.c But in this specific situation this build file will be utilized by python as an extension module.
@ambeshsingh1251
@ambeshsingh1251 3 года назад
@@Pythonist i tried the same but i am getting multiple errors. Maybe because the generated C file does not have a main method. Please suggest how can i run the generated .c file. Do i need write a separate .c file and call the generated .c file from there. Thanks in advance
@mohsenkeshtkar446
@mohsenkeshtkar446 3 года назад
Thank you for the tutorial. I try your codes on my system but the results were not the same. My runtime was 9 second for limit=1000 utilizing cython. Could you please let me know your system information like RAM, SSD, HDD, number of cores and etc.?
@Pythonist
@Pythonist 3 года назад
I run this code at Macbook Pro with 8gb RAM, 2.3 GHz core i5 and SSD.
@mohsenkeshtkar446
@mohsenkeshtkar446 3 года назад
@@Pythonist Great! Thanks for your response.
@destiny_02
@destiny_02 3 года назад
Pythonist or Pythonest ?
@Pythonist
@Pythonist 3 года назад
Initially It was Pythonest but now it is Pythonist :)
@manashmondal2635
@manashmondal2635 5 лет назад
would you plz tell me the name of your VSCode theme?
@Pythonist
@Pythonist 5 лет назад
I'm using the "Dracula" color theme with Material Icon theme.
@philtoa334
@philtoa334 4 года назад
Nice.
@Pythonist
@Pythonist 4 года назад
Thank you! Cheers and stay tuned:)
@chromebookmark646
@chromebookmark646 2 года назад
great, but where is nuitka?
@jeetvadera3217
@jeetvadera3217 3 года назад
Nice video
@Pythonist
@Pythonist 3 года назад
Thanks, stay connected!
@Saimon404
@Saimon404 3 года назад
How to decrypt anti Uncompyle6
@Pythonist
@Pythonist 3 года назад
Couldn't got your point, explain your question a bit more, please!
@abhishekmantri8922
@abhishekmantri8922 4 года назад
8:43 while trying to compile python to cython via setup.py I am getting error Unable to find vcvarsall.bat Please help Great Video
@Pythonist
@Pythonist 4 года назад
Firstly, Just add import "setuptools" as "import setuptools" at the very top, that will help Python and "C++ Compiler " work together. Secondly, If you are on windows, you many need to Install Microsoft Visual C++ Compiler for Python.
@abhishekmantri8922
@abhishekmantri8922 4 года назад
@@Pythonist This method worked, Thanks for your help... I have two more query, setup has created multiple files, how many of them are useful to import script. Can someone decrypt /decode my source code out of the file this process generates?
@abhishekmantri8922
@abhishekmantri8922 4 года назад
Setup has created the following files. C source file Exp file LIB file 3D object Python extension module How many of these are useful to run the script successfully?
@Pythonist
@Pythonist 4 года назад
This can be decoded but if security is your concern then you can make the process of decryption near to impossible by some tweaks, also you the extension model file .so can be utilized in this case.
@Pythonist
@Pythonist 4 года назад
You will need .c source file & Python extension .so file to run this script.
@giovannidigiannatale7794
@giovannidigiannatale7794 4 года назад
If i try to import the numpy module inside the file.pyx I get an error. Without importing numpy the script works. Unfortunately I need to import several modules like scipy and so on and using them as simple python modules. How can I do?
@Pythonist
@Pythonist 4 года назад
If you are using Numpy's array then you have to import in this way: import numpy as np cimport numpy as np and must call this method: np.import_array()
@shuozi
@shuozi 2 года назад
funny accent
@Pythonist
@Pythonist 2 года назад
Was an issue in Audio editing.... now fixed .... watch the latest videos on the channel!
@Hussamaldeen-n1p
@Hussamaldeen-n1p 4 года назад
your accent is hard to understand
@Pythonist
@Pythonist 4 года назад
I will try to improve but meanwhile, you can use closed captions to get better understanding.
@Pythonist
@Pythonist 4 года назад
@AMAGED, can take a look at the new videos and provide your kind feedback? Is it more clear, easy to understand now?
@MagnusAnand
@MagnusAnand 4 года назад
Great video!
@MagnusAnand
@MagnusAnand 4 года назад
Where are you? Your channel has no activity 😱
@Pythonist
@Pythonist 4 года назад
First of all, thank you for your kind feedback. I'm back and posting new videos, stay tune and keep watching!
Далее
Numpy in Python | how numpy can optimize our code
15:52
Compiled Python is FAST
12:57
Просмотров 112 тыс.
Little kitten 💓💜❤️🥰
00:17
Просмотров 18 тыс.
25 nooby Python habits you need to ditch
9:12
Просмотров 1,8 млн
Make Python code 1000x Faster with Numba
20:33
Просмотров 444 тыс.
Premature Optimization
12:39
Просмотров 815 тыс.
Simple Code, High Performance
2:50:14
Просмотров 253 тыс.
Just enough C to have fun
39:29
Просмотров 51 тыс.
My 2 Year Journey of Learning C, in 9 minutes
8:42
Просмотров 620 тыс.
This Algorithm is 1,606,240% FASTER
13:31
Просмотров 838 тыс.
CppCon 2014: Mike Acton "Data-Oriented Design and C++"
1:27:46