from Hacker News

Writing a Python C extension in 2018

by jbaviat on 5/16/18, 11:13 PM with 1 comments

  • by jbaviat on 5/16/18, 11:13 PM

    I'm the author of https://github.com/sqreen/PyMiniRacer, used as example in this deck.

    I introduce how I leveraged ctypes + Python manylinux wheels (PEP513 / PEP571) in order to allow loading V8 easily into Python, without requiring local compilation on install nor having us maintaining a huge test matrix:

        $ pip install py-mini-racer
        $ python
        >>> from py_mini_racer import py_mini_racer
        >>> ctx = py_mini_racer.MiniRacer()
        >>> ctx.eval('1+1')
        2
    
    
    So this shared object could be used in any language allowing to interact with arbitrary shared objects (e.g. Ruby with fiddle).