4 ms·
Agreed. Have given list a try actually, the speed is better, but still not efficient enough.
by overnover 14y ago
Agreed. Have given list a try actually, the speed is better, but still not efficient enough.
- dragonwriter 14y agoPython lists are dynamically resizable, unlike normal C arrays, and can hold arbitrary objects. They aren't going to ever be as efficient as C arrays -- while they aren't as "big" as defaultdict, they are a lot more than simple C arrays. Python arrays should be more efficient for homogenous arrays of one of the types they are specialized for (including ints), and if the performance of the list/array is really a bottleneck in your application, there are more specialized tools available (including moving that bit off into a C extension). There are certainly places where every bit of performance out of a collection matters, but there are more places where being able to quickly put together code that works correctly matters (for one thing, being able to quickly put together correct code makes it possible to correctly identify the bottlenecks where you need to optimize performance.)
- overnover 14y agoTrue, and I like python list alot as it offer the ability to hold heterogenous objects and it's really flexible & simple. Just happened to using list the other day to cache a large 2d array, which turned out to be slow. Certainly, my implementation has room for improvement, and my comparison isn't straightly an apple to apple. Taken down the post n modifying. Thanks for the comment btw.