Reduce the number of allocation/reuse allocation of ndarray #1943

#1943 
@nouiz 

Hey, Fred, this is my draft idea, is the direction right?

If the direction is right, what I wanna do in the future is fill the details, and optimize it to reduce the "if" inside the loop.
It is better to do:
```
for idx in range(order):
  node = order[idx]

```
This will be faster, as `index` take time linear to the number of node in order. The above code will be constant time in the number of node in order.