Skip to content

Instantly share code, notes, and snippets.

@thenoviceoof
Last active December 14, 2015 06:49
Show Gist options
  • Save thenoviceoof/5045411 to your computer and use it in GitHub Desktop.
Save thenoviceoof/5045411 to your computer and use it in GitHub Desktop.
Oh god this is such a terrible idea
import timeit
# introducing a C primitive to the Python namespace for fun and profit
# if you're familiar with the way Python-C modules are usually built,
# you'll notice this is abstracting way a bunch of things,
# which may or may not be possible
# syntax: C <ret_type> <name>(...<params>...) with {<header>: <library>}
C str fn_name(int something) with {'stdio.h': 'stdlib', 'math.h': 'm'}:
// blah blah blah
something += 2;
char *s = malloc(sizeof(char)*5000000000);
return sprintf(s, "%d", something);
assert '22' == fn_name(20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment