I am currently trying to build a program where I have a recursive function that for every loop appends one new element to the array it is building. I didn't want to use the append function that many times, because my function is supposed to do a large number of loops, and I've come to learn from previous experiences that the append function in general takes a lot of time. I've tried to look everywhere for a function that simply adds one element to the tail of the array, but I've found nothing of such sort. So I was thinking I would ask here.
So my question is basically: "Is there a more effective way of adding one element to the back of an array than using append?"
Updated with a new question regarding the previous one
So I used a list instead, inserting each new element as a head, and reverted the list when the function was finished. This made the function about 70 times faster. But the problem remains as I have another function that does pretty much the same, which became about 4 times slower, increasing the overall time for my main function. The functions are very similar. The first function (the one that became much faster) produces ints, adding each new int to the list. The second function (the one that became much slower) produces an object, adding each new object to the list. Does anyone have an idea why one function became so much faster while the other one became so much slower?