Cython 3.0: Compiling Python to C, the next generation

Поделиться
HTML-код
  • Опубликовано: 5 окт 2024
  • The Cython project compiles Python to C -- not just to make code faster, but also to wrap external C libraries easily, and make it easy to write C extensions for Python generally. Cython 3.0 is a major overhaul of the project. Learn in this video what's new about it, why it's worth upgrading your Cython code to use its features, and some pitfalls to avoid along the way.
    I talk more about the basics of Cython here:
    www.infoworld....
    More here about the CPython limited API, and other future changes to CPython:
    www.infoworld....
    -----------------------------­---
    SUBSCRIBE: www.youtube.com...
    FACEBOOK: / infoworld
    TWITTER: / infoworld
    WEBSITE: www.infoworld.com/

Комментарии • 14

  • @luabida
    @luabida Год назад +1

    Cython 3.0 release caused so much python packages to crash lately 😆 I NEED to get use to write cython alongside with my python code

  • @mfatihaydogdu7
    @mfatihaydogdu7 11 месяцев назад +2

    Great video. Why not to make a tutorial series for Cython?

    • @InfoWorld
      @InfoWorld  11 месяцев назад +6

      Yes, I have plans for more Cython videos on the way!
      -Serdar

    • @alicenogueira5972
      @alicenogueira5972 8 месяцев назад

      @@InfoWorld please do

  • @UpYours101
    @UpYours101 Год назад +1

    Thanks for the info.

  • @nikolatrinh
    @nikolatrinh 9 месяцев назад +1

    Hello, I just learned about Cython and I have a question. I want to package the Cython program into an .exe file to run on the Win10 operating system. I tried to do it with Pyinstaller like I did with the previous versions. Python files but without success. Looking forward to receiving an answer from you. Thank you very much.

  • @zimrihidaf
    @zimrihidaf Год назад +1

    is there a way to get pytorch models through onnx or another medium to perform inference fast with cython code? for example if your game of like code was instead a simulation of some sort where predictions would need to be made from a neural network?

  • @pietraderdetective8953
    @pietraderdetective8953 11 месяцев назад

    hi Serdar, great video you got here!
    A quick question: should we expect a lot of differences in execution speed between running Cython vs the pure python mode? I just did a quick test in Google Colab and the pure python implementation is like twice slower than Cython's speed.
    Is this to be expected or something's wrong with my workflow?

    • @pietraderdetective8953
      @pietraderdetective8953 11 месяцев назад

      to be more precise, this is the performance numbers for a Fibonacci function:
      *Python: 2.54 microsecond
      *Cython: 211 ns
      *Cython pure-python mode: 630 ns
      --> as you can see, while the pure python mode is still significantly faster than the original Python code, but it's several magnitudes slower than the Cython code.

    • @InfoWorld
      @InfoWorld  11 месяцев назад +1

      One thing to make sure of is whether or not you're using the correct types for your pure-Python implementation. For instance, an int type decoration is a Python int, not a C integer, so you need to use Cython's type decorations for ints to get C ints. You may want to use the source annotation feature, which generates a color-annotated version of your Cython source so you can see at a glance what parts of the code are still beholden to Python types, and what parts have been lowered to pure C.
      -Serdar

  • @blueman333
    @blueman333 Год назад

    One thing that has always restricted me to use cython was no proper way of handling matrices or strings as input to c functions. I wanted to input a matrix of strings into cython, and could not find a proper documentation

    • @amirarjmand5295
      @amirarjmand5295 11 месяцев назад

      So is this tool not proper for ML (python to C++)?

  • @BROTHERsGAMinglive
    @BROTHERsGAMinglive 9 месяцев назад

    please make tutorial for cython

  • @SHONNER
    @SHONNER Год назад

    .pxd file? I'll have to check it out.