DEV Community

Omar Hussein
Omar Hussein

Posted on

Answer: Initialising an array of fixed size in python [duplicate]

Why don't these questions get answered with the obvious answer?

a = numpy.empty(n, dtype=object)

This creates an array of length n that can store objects. It can't be resized or appended to. In particular, it doesn't waste space by padding its length. This is the Python equivalent of Java's

Object[]

Top comments (0)