Reputation: 95
I've got a list of around 6000 (text) objects, which I am trying to store and pass values from it (after manipulation) to another list. I am using the append
and extend
functions.
The program works fine and gives me the desired result, but it is too slow.
How can I increase its performance (without using С code in my program)?
Upvotes: 2
Views: 6655
Reputation: 704
You are after the collections
module (included with Python).
This module implements specialized container datatypes providing alternatives to Python’s general purpose built-in containers.
At the top we see:
deque: list-like container with fast appends and pops on either end
from collections import deque
items = deque([1,2,3])
items.pop()
items.extend()
items.append()
Upvotes: 2