All Questions
17 questions
2
votes
0
answers
73
views
a C/Python X server interface extension package
The project is named winlin; it's a portmanteau of the words window and Linux.
I'm working on a CPython extension to interact with the X server and manipulate windows. I don't have a ton of ...
5
votes
3
answers
379
views
HackerRank challenge: Box Operations
Recently I've been doing some challenges on HackerRank and came across this one. First, I tried with Python and then with C. Both of my codes failed due to timeout restrictions.
It would be very ...
6
votes
1
answer
1k
views
Transfer an array of unknown size from C to Python using Ctypes
I am new to Ctypes. I am writing a piece of code that brings an array of unknown size from C to Python using Ctypes. Unknown size here means that Python initially doesn't know the size of the array. ...
3
votes
1
answer
141
views
C function to fully consume a Python iterator
I was reading into the proper way to consume an iterator on this question as well as here and I notices there is no actual proper function for this that clearly explains itself.
Using:
...
2
votes
1
answer
331
views
Simple Python module to test dictionaries
I have some hardware for which I have a driver for which I have a library which can be used to easily configure and probe the device. Now I want to add support for this library to python because the ...
13
votes
2
answers
2k
views
Prime generator in Python and C
I have written the Rabin-Miller test in Python and ported it to C. But somehow, the C version is ~20 times slower on my system, and I am not sure how. Anyway, here is my code.
Python
...
12
votes
2
answers
2k
views
"Longest Collatz sequence" in C slower than in Python 3
This tight-looped memoization-less C solution to Project Euler's problem 14 seems efficient, but ran much slower than a similarly trivial Python 3 program. For the desired ...
3
votes
1
answer
4k
views
Remove comments from C-like source code
I am working on the problem of removing comments from C-like source code. Here is my code in Python 2.7, and if anyone could advise improvement areas (especially performance), or any functional bugs ...
14
votes
3
answers
5k
views
Lexer for C- in Python
I am currently taking a compilers course where we are designing a compiler for C- (which is a subset of C). Our first step was the lexer and I have written that but I believe that it is not very "...
8
votes
2
answers
135
views
Python code to run a C program that calculates whether points are in the mandelbrot set
This is part of a project to explore the Mandelbrot set. The code to graphically navigate the complex plane and allow the user to adjust the colormap and number of iterations is all written in Python, ...
26
votes
3
answers
3k
views
"The python that ate a calculator"
In a YouTube video I watched, the speaker said it is important to know how to calculate between numbers of different bases; i.e. two, ten, and sixteen. I was then inspired to write a small C program ...
14
votes
2
answers
9k
views
Possible optimizations for calculating squared euclidean distance
I need to do a few hundred million euclidean distance calculations every day in a Python project.
Here is what I started out with:
...
2
votes
1
answer
182
views
Are these set-uid scripts/binaries secure?
I have a system that needs to be able to reboot a different piece of hardware partway through a script that programs it. It used to wait for me to come and reboot the hardware halfway through, but I'...
3
votes
2
answers
554
views
creating a hash based sorting algorithm
For experimental and learning purposes. I was trying to create a sorting algorithm from a hash function that gives a value biased on alphabetical sequence of the string, it then would ideally place it ...
7
votes
2
answers
303
views
Linspace method build in Python's C API
Today I built a linspace function in Python's C API:
...