Tagged Questions
0
votes
0answers
57 views
Bit array not working as fast as expected [closed]
I recently downloaded the bitarray module from here, for a faster prime sieve, but the results are dismal.
from bitarray import bitarray
from numpy import ones
from timeit import timeit
def ...
2
votes
1answer
202 views
Snake game — made with Python
I wrote a simple Python snake game, it's about 250 lines of code. Can someone give me some advice on how to refactor/make it better?
game.py
# game.py - 3/22/2013
import pygame, sys, os
from ...
3
votes
4answers
225 views
How make array search more efficient in python?
Here is Python code written to perform the following operations:
Find each occurrence of a three-letter sequence in a character array (e.g. a sequence such as ('a','b','c')), including overlapping ...
4
votes
1answer
137 views
Optimizing Python / Numpy Code
So I'm implementing a version of the mean shift image processing algorithm for color segmentation in python/numpy.
I've written a pure numpy version of the actual mean shifting per pixel (which I ...
5
votes
1answer
97 views
Sparse Bitarray Class in Python (or rather frequently having contiguous elements with the same value)
Sparse is probably the wrong word - this is for encoding arrays of booleans where contiguous values tend to be the same. It'd be great to know a proper name for this data structure so I could read ...
1
vote
1answer
99 views
What specific optimizations can be made to this BitArray class, and how can they be implemented?
Here is the current code for the BitArray class needing optimization (implemented on big integers):
import itertools
################################################################################
...
1
vote
2answers
302 views
Python: optimize this rolling loop
I have a numpy array of about 2500 data points. This function is called on a rolling basis where 363 data points is passed at a time.
def fcn(data):
a = [data[i]/np.mean(data[i-2:i+1])-1 for i in ...
1
vote
3answers
438 views
Multiline Input into Python Arrays
I've knocked together a few lines of python to read in stats for a service (haproxy), and store them in an array (to do some analysis on later). It basically takes a multiline output, and splits it ...