Under the hood vim.list_extend() does the same loop over the source table and uses table.insert() to append the values to the destination table, so using a temporary table makes little sense. Switch to directly inserting (appending) values into history_lines table.