Python Forum
library for C but written in Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
library for C but written in Python
#1
has anyone here ever created a library for C but written in Python? i assume the hardest part is the arguments and their types. is there any particular documentation or developed code focusing on this aspect of development (making Python work to be a library that C code could call? on freedom i might expect is if the library API is being developed with this, it could focus on aspects on an API that can be easy in both languages (i.e.avoid the hard ways to pass args or provide C/Python layers to make this easier.
Gribouillis likes this post
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
(Apr-15-2024, 02:47 AM)Skaperen Wrote: has anyone here ever created a library for C but written in Python? i assume the hardest part is the arguments and their types. is there any particular documentation or developed code focusing on this aspect of development (making Python work to be a library that C code could call? on freedom i might expect is if the library API is being developed with this, it could focus on aspects on an API that can be easy in both languages (i.e.avoid the hard ways to pass args or provide C/Python layers to make this easier.

When I was creating a C library using Python, I primarily used Cython to write Python code that compiles into a C extension. I referred to the Cython documentation extensively to handle data types and memory management correctly. Additionally, I made sure the API design was straightforward, using common data types and consistent error handling to bridge the two languages effectively.
Gribouillis and Skaperen like this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trading Bot written in Python for Windows Pizzlew 1 52,483 Sep-26-2022, 04:42 PM
Last Post: snippsat
  [Software suggestion] Video player written in Python? ThePhi 2 2,603 Dec-10-2018, 07:14 PM
Last Post: ThePhi
  Why isn’t there any good hacking books written in Python 3 Takeshio 8 11,271 Aug-26-2018, 09:19 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020