[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Modern Lua binding library
- From: Hisham <h@...>
- Date: Tue, 15 Mar 2016 01:49:12 -0300
On 14 March 2016 at 18:22, Jonathan Goble <jcgoble3@gmail.com> wrote:
> On Mon, Mar 14, 2016 at 5:06 PM, ThePhD <jm3689@columbia.edu> wrote:
>> Dear Everyone,
>>
>> [long rant]
>
> I agree. Although I've not dug into it much, and not tried to write
> any code for it, I prefer Python's C API over Lua's, because Python
> defines a `PyObject *` pointer that can be used to point to an
> arbitrary Python value, without need for complicated stack operations.
> And building on that, Python functions written in C receive their
> positional arguments as a `PyObject *` tuple passed directly as an
> actual argument to the C function. (The method of unpacking that tuple
> into C values is a bit clunky, but in my uneducated opinion, worth the
> trade-off.)
>
> I'd love to see something similar to that for Lua.
Python's C API looks much simpler on surface, indeed, but it has one
complication that breaks the deal: garbage collection. This is the one
thing that Lua's stack oriented API gives you for free, and it's its
killer feature. Ask anyone who has coded significantly with Python's C
API and the one thing they'll complain you about is having to deal
explicitly with reference counting for GC.
-- Hisham