How to autoGenerate C bindings for Django 1.11 ?

48 views
Skip to first unread message

Etienne Robillard

unread,
Jan 23, 2018, 4:33:14 AM1/23/18
to django...@googlegroups.com, django-...@googlegroups.com
Hi,


I would like to know if it would be possible to autogenerate C bindings
for the whole Django package in Cython or similar extension.

What do you think? :)

Cheers,

Etienne


--
Etienne Robillard
tka...@yandex.com
https://www.isotopesoftware.ca/

Etienne Robillard

unread,
Jan 23, 2018, 2:57:22 PM1/23/18
to django...@googlegroups.com, django-...@googlegroups.com
Can I create a file named libdjango.pyx with the following code:

{{{

import django

from django import *

}}}

Then compile the C file with gcc to access django in C ?

Etienne

Avraham Serour

unread,
Jan 23, 2018, 5:18:19 PM1/23/18
to django-users
Did you try doing this and see what happens?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5b89eee2-b69e-f35b-4a8f-ac3bbb362cda%40yandex.com.
For more options, visit https://groups.google.com/d/optout.

Etienne Robillard

unread,
Jan 24, 2018, 4:21:41 AM1/24/18
to Django users
Hi Avraham

 
On Tuesday, 23 January 2018 17:18:19 UTC-5, Avraham Serour wrote:
Did you try doing this and see what happens?

Not yet. But I presume I could just use the libdjango.so shared library as a replacement for the django package?

Regards,

Etienne

On 23 Jan 2018 9:56 PM, "Etienne Robillard" <tka...@yandex.com> wrote:
Can I create a file named libdjango.pyx with the following code:

{{{

import django

from django import *

}}}

Then compile the C file with gcc to access django in C ?

Etienne


Le 2018-01-23 à 04:32, Etienne Robillard a écrit :
Hi,


I would like to know if it would be possible to autogenerate C bindings for the whole Django package in Cython or similar extension.

What do you think? :)

Cheers,

Etienne



--
Etienne Robillard
tka...@yandex.com
https://www.isotopesoftware.ca/

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

Avraham Serour

unread,
Jan 24, 2018, 4:58:21 AM1/24/18
to django-users
please try and share your findings, I'm sure I'm not the only one curious about this


To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Jason

unread,
Jan 24, 2018, 6:11:08 AM1/24/18
to Django users
I'm curious about this to, but am struggling to see the use case for this.  Could you elaborate on how you'd use something like this, and its expected benefits?

Etienne Robillard

unread,
Jan 24, 2018, 6:28:32 AM1/24/18
to django...@googlegroups.com, django-...@googlegroups.com
Hi Jason,


Le 2018-01-24 à 06:11, Jason a écrit :
I'm curious about this to, but am struggling to see the use case for this.  Could you elaborate on how you'd use something like this, and its expected benefits?

The goal would be to use faster C code for accessing Django internal api.

Then I suppose you could build precompiled a Django binary for specific architectures/compilers (like llvm) :)

Here is my results so far:

erob@marina:~/src/django-hotsauce-devel$ python
Python 2.7.13 (default, Nov 24 2017, 17:33:09)
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libdjango
>>> libdjango
<module 'libdjango' from '/home/erob/src/django-hotsauce-devel/lib/libdjango/__init__.pyc'>
>>> dir(libdjango)
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__']
>>> libdjango.main
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'main'
>>> import libdjango.main
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define init function (initmain)

erob@marina:~/src/django-hotsauce-devel/lib/libdjango$ cat libdjango.pxd
from django import *

erob@marina:~/src/django-hotsauce-devel/lib/libdjango$ cat libdjango.pyx
from libdjango cimport *


Any ideas why the dynamic module does not define init function?




You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

For more options, visit https://groups.google.com/d/optout.

Etienne Robillard

unread,
Jan 25, 2018, 4:15:32 AM1/25/18
to django...@googlegroups.com, django-...@googlegroups.com

Is it possible to wrap Django API into public C methods in Cython?

I'm thinking I could define a few functions in my libdjango.pyx typically used for Django administration.

What do you think?

Etienne
--
You received this message because you are subscribed to the Google Groups "Django hotsauce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-hotsau...@googlegroups.com.
To post to this group, send email to django-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-hotsauce/99d0931e-2a14-c977-5519-6bcac70637c0%40yandex.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages