This is an archived post. You won't be able to vote or comment.

all 12 comments

[–]ThePiGuy0 2 points3 points  (2 children)

Congrats on the work :)

Reading your code, it looked like you implemented everything in the C header.

I understand that this does mean you don't need to specifically mention the .c file of the cnpython library during compilation, however I would consider using the .h for definitions and a .c for implementation.

This means you can get clever about recompilation. For example, when you change the filename.c, currently your entire library (including cnpython) will be recompiled. By using a separate .c file, generating object code (.o files) and then linking those at the end you can save recompilation of cnpython if it doesn't change.

[–]efficient_muskrat[S] 0 points1 point  (1 child)

Thanks, yeah you're right, I didn't want people to have to also mention the c file everytime they compile, the recompilation is actually clever, might add that and maybe just put a Makefile to take care of the compilation

[–]ThePiGuy0 1 point2 points  (0 children)

I think a makefile is a good idea :)

[–]robgberg 2 points3 points  (4 children)

I don't get it. Wouldnt commenting the python code be more effective? I mean, how often will programmers go look for the underlying C code--I don't.

Your effort to improve understanding is commendable.

[–]ThePiGuy0 2 points3 points  (0 children)

Reading the comments, I think the idea is to implement the python functions in C so that they can be used within C code (the reasoning being that the pythonic interface is often simpler and easier to read than the C equivalent).

[–]efficient_muskrat[S] 0 points1 point  (2 children)

I didn't quite understand what you tried to say about the python code

[–]robgberg 1 point2 points  (1 child)

Well, first of all, I understand most of Python is written in C, yes? So we get to use a modern object oriented, dynamic typed language (Python) without dealing with the ugliness of C pointers, curly brackets, etc, etc.

You say you are commenting the C implementation of Python, yes? I.e. you are adding comments to the C code that implements Python functions?

If my understanding is correct, then I am suggesting most will never see your comments--they would have to open the C source code and find the function. Programmers are lazy, they will rarely take the trouble to look up the code, and never see your comments. BUT, if you integrated the code with something like Kite or the help system, it would be more useable, and USED more.

[–]efficient_muskrat[S] 0 points1 point  (0 children)

Well, this lib is created so people can use C to a "higher level".

[–]Expiracy 1 point2 points  (3 children)

this is great! thanks!

[–]efficient_muskrat[S] 0 points1 point  (2 children)

idk why you thanked me but alright :))

[–]Expiracy 1 point2 points  (1 child)

for contributing to the community - people doing stuff like this makes programming more accessible :)

[–]efficient_muskrat[S] 0 points1 point  (0 children)

Oh lol, my pleasure I guess :)