What is the best way to speed up python
I only want a suggestion for the complete learning faster the python. So please guide me , what is the best way to learn python faster little more due to less time I am not just declared that python is best it was not my attention it's a big goal to me that I want to focus python with my study
7/27/2021 7:19:00 AMNavneet Singh
9 AnswersNew Answer
Navneet Singh You can take help from there and also take a practical too this will help you retain everything 💯😄 https://www.sololearn.com/discuss/1391682/?ref=app https://www.sololearn.com/discuss/1629189/?ref=app https://www.sololearn.com/discuss/2343116/?ref=app
Use C/C++. https://docs.python.org/3/extending/extending.html why do you think so many Python libraries are little more than wrappers around C or C++ code?
Calvin Thomas, No CPython is not as fast as C. CPython is the reference implementation of Python using C, it is still an interpreted language. Though it depends on what you are doing. If the bulk of the code is calling library functions implimented in C it could be close to C in performance. Jython is an implementation of Python in Java while IronPython is a .NET implementation. The implementation language refers to the language that the Python interpreter is written in.
Calvin Thomas, I am not aware of any such compiler (though that does not mean such a compiler does not exist). However, since a C compiler generates native code from the source it is able to perform various optimisations at this level. Transpiling Python byte code into native code would give an improvement but would still not be to the same extent as native C code. You still have the problem that Python is not strongly typed so it would not be possible to optimise code by using variables of the optimal data type e.g. there is no way of knowing what data type myvar is going to contain at any given moment, this all has to be handled at runtime. Effectively what you would end up with is a result similar to a "Just In Time" (JIT) compiler output similar to what Java uses; though JIT compilation occurs at runtime. CPython does not have a JIT compiler, though I believe Jython does. I'm not sure about IronPython. Disclaimer: I'm no Python expert and I don't particularly like the language. I simply looked into it to see what all the fuss was about and because Blender uses it as a scripting language. I haven't actually used it in Blender yet as I'm still learning Blender.
Martin Taylor Is Cython nearly as fast as C?
Martin Taylor What if someone makes a compiler for Python that converts the Bytecode into machine code? Would it still be slower than C? I have always been wondering why no one does this. Thank you.
Martin Taylor Oh, I see. So I suppose that the optimisation the compiler has to do will be very tedious as a single variable can contain any data-type. Thank you very much for your valid response.
Calvin Thomas you can look up “Nuitka”. it’s a Python “compiler” after all and can generate binaries.
Flash Cool! Although it still doesn't result in code efficiencies matching that of C, it's a good enough improvement over Cython, it seems.