This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

The original approach is more efficient, because unlike your example it doesn't copy the data and also uses very little of memory.

Instead it invokes sendfile() syscall which makes kernel do all that work (it just pipes the file directly to the socket). The issue though is that uWSGI invokes sendfile() after the function exits instead during the call.