I have about 10million values that I need to put in some type of look up table, so I was wondering which would be more efficient a list or dict?
I know ... |
Based on this older thread, it looks like the cost of list functions in Python is:
- Random access: O(1)
- Insertion/deletion to front: O(n)
- Insertion/deletion to back: O(1)
Can anyone confirm whether this is ... |
I am looking for advice about how to parse a single list, using two nested loops, in the fastest way, avoiding doing len(list)^2 comparisons, and avoiding duplicate files in groups.
More precisely: ... |
My adventures with entity groups continue after a slightly embarrassing beginning (see Under some circumstances an App Engine get_by_key_name call using an existing key_name returns None).
I now see that I ... |
I need a very large list, and am trying to figure out how big I can make it so that it still fits in 1-2GB of RAM. I am using the ... |
Suppose I have two lists, L and M. Now I want to know if they share an element.
Which would be the fastest way of asking (in python) if they share an ... |
What´s the most efficient, elegant and pythonic way of solving this problem?
Given a list (or set or whatever) of n elements, we want to get the k biggest ones. ( You ... |
|
I'm trying to solve this programming riddle and although the solution (see code below) works correctly, it is too slow for succesful submission.
- Any pointers as how to make this ...
|
I have a big file I'm reading from, and convert every few lines to an instance of an Object.
Since I'm looping through the file, I stash the instance to a list ... |
Problem Hey folks. I'm looking for some advice on python performance. Some background on my problem:
Given:
- A
(x,y) mesh of nodes each with a value (0...255) starting at ... |
Fastest way to uniqify a list in Python without preserving order? I saw many complicated solutions on Internet - could they be faster then simply:
list(set([a,b,c,a]))
?
|
Hey guys, -- I just parsed a big file and I created a list containing 42.000 strings/words. I want to query [against this list] to check if a given word/string belongs ... |
I've been trying to apply an algorithm to reduce a python list into a smaller one based on a certain criteria. Due to the large volume of the original list, in ... |
In Python, which data structure is more efficient/speedy? Assuming that order is not important to me and I would be checking for duplicates anyway, is a Python set slower than a ... |
I need a collection data-structure that can do the following:
- Be sorted
- Allow me to quickly pop values off the front and back of the list O(log n)
- Remain sorted after I insert a ...
|
I'm doing some indexing and memory is sufficient but CPU isn't. So I have one huge dictionary and then a smaller dictionary I'm merging into the bigger one:
big_dict = {"the" : ...
|
I need to process lots of data in lists and so have been looking at what the best way of doing this is using Python.
The main ways I've come up ... |
Suppose I have the following object:
class Foo(object):
def __init__(self, name=None):
self.name = name
def __repr__(self):
return self.name
And a list containing multiple instances, such ... |
I want to compare if value of one list exist in value of other list.They are huge (50k + items, from database).
EDIT:
I also want to mark the record which is ... |
So, I notice that calling array[:-1] is going to clone the array.
Say I have a large array with like 3000 elements in it. I don't want it to be cloned ... |
This is almost the same question than here, except that I am asking about the most efficient solution for a sorted result.
I have a list (about 10 integers randomly between ... |
Is there any any faster way to swap two list elements in Python than
L[a], L[b] = L[b], L[a]
or would I have to resort to Cython or Weave ... |
I have a file with 40 million entries in the form of:
#No Username
And I have a list with 6 million items, where each item is a username.
I want to find the ... |
Is there a list of the different data structures and their big-O access times for Python?
I was rummaging through the standard library docs and didn't see any, hence the question. :-)
... |
What would be an efficient and pythonic way to check list monotonicity? i.e. that it has monotonically increasing or decreasing values?
Examples:
[0,1,2,3,3,4] # This is a monotonically increasing list
[4.3,4.2,-2] # This ...
|
I have just found these performance notes for cPython lists:
Time needed for python lists to ....
- ... get or set an individual item: O(1)
- ... append an item to the list: ...
|
I'm in need of a method to quickly return the number of differences between two large lists. The contents of each list item is either 1 or 0 (single integers), and ... |
I have a list and in each list element, I need some details.
What will be more efficient to use the list in the list
[['brown', 'wood', 2], ['red', 'box', 3 ... |
I'm looking for an efficient way of achieving this, which I think is a slicing-like operation:
>>> mylist = range(100)
>>>magicslicer(mylist, 10, 20)
[0,1,2,3,4,5,6,7,8,9,30,31,32,33,34,35,36,37,38,39,60,61,62,63......,97,98,99]
the idea is: the slicing gets 10 elements, then skips 20 ... |
I was testing the speeds of a few different ways to do complex iterations over some of my data, and I found something weird. It seems that having a large list ... |
I have a project where I am reading in ASCII values from a microcontroller through a serial port (looks like this : AA FF BA 11 43 CF etc)
The input is ... |
I want to create a very simple spell checker using a text file with an alphabetized list of about 80000 common words.
What's a simple but efficient way to search the ... |
I'm referring to this: http://docs.python.org/tutorial/datastructures.html
what would be the running time of list.index(x) function in terms of big O notation?
|
Suppose you have got a list comprehension in python, like
Values = [ f(x) for x in range( 0, 1000 ) ]
with f being just a function without side effects. So all ... |
What is the best way to split a large list (over 1000 items) for performance purposes? And use "parts" of a large list?
For example; I have a list of 10k addresses ... |
I'm wondering because I need to have have a function that is disgustingly fast at checking if a word is in a dictionary list - I'm considering leaving the dictionary as ... |
After a search, and some test runs both os.popen()+read() and subprocess.check_output() seem to be almost equivalent for reading out the contents of a folder. Is there a way to improve either ... |
Let's say my list is about 1,000,000 entries long. To acess an item, the time would be O(500,000), which seems very long to me.
What happens when I split the ... |
Given:
Two csv files (1.8 MB each): AllData_1, AllData_2. Each with ~8,000 lines. Each line consists of 8 columns.
[txt_0,txt_1,txt_2,txt_3,txt_4,txt_5,txt_6,txt_7,txt_8]
Goal:
Based on a match of txt_0 (or, AllData_1[0] == AllData_2 ), ... |
I am updating a legacy Python script, and was wondering if it is possible to unwrap a list from inside another list, or more generally to unwrap a list into just ... |
I have a list of many Python objects like this:
class RangeClass(object):
def __init__(self,address,size):
self.address=address
...
|
I am currently using Python 2.7. I currently have three columns in an Excel document all with different integer values in. The amount of values can vary ranging from 10 through ... |
I currently have a requirement to make a comparison of strings containing MAC addresses (eg. "11:22:33:AA:BB:CC" using Python 2.7. At present, I have a preconfigured set containing the MAC address ... |
I already know how to remove all duplicates from List by using set:
ls = list(set(ls))
What i want to know is there any way to remove all duplicates except one element instances, ... |
I have run into an oddity with creating nested lists in Python 2.6.6.
Consider the following two functions:
def lists(n):
start_time = time.time()
lists = [None]*n
...
|