Photo by João Vítor Heinrichs from Pexels

Python vs JavaScript: Lists

--

A simple comparison between Python list and JavaScript Array - mutable sequences of a dynamic size and an unrestricted content type.

Python 3 and a “modern” JS engine are assumed (V8, SpiderMonkey, JavaScriptCore).

Python List vs JS Array

Time complexity of common operations

Amortized worse case complexity

Pitfalls

Common recipes

Alternatives

Python

Tuple, str, bytes - immutable sequences
Bytearray - mutable sequences of bytes
Deque - stack and queue sequences
Array - efficient typed lists
NumPy array - powerful n-dimensional typed arrays from NumPy library

JavaScript

Build-in TypedArrays - mutable sequences of bytes

--

--

No responses yet