rfc:implicit_move_optimisation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
rfc:implicit_move_optimisation [2023/05/13 22:46] – clarify nielsdosrfc:implicit_move_optimisation [2023/05/14 16:24] (current) – spell out ETL nielsdos
Line 28: Line 28:
 The code example shows an array being passed to "my_function", which modifies the array and returns the modified result. However, due to the copy-on-write (CoW) mechanism, the variable "$my_array" is copied within "my_function" because the array's reference count is greater than 1 and it is modified. In this example, the copy is unnecessary because the result always overwrites the original array. The purpose of this RFC is to propose an optimisation for avoiding such unnecessary copies. The code example shows an array being passed to "my_function", which modifies the array and returns the modified result. However, due to the copy-on-write (CoW) mechanism, the variable "$my_array" is copied within "my_function" because the array's reference count is greater than 1 and it is modified. In this example, the copy is unnecessary because the result always overwrites the original array. The purpose of this RFC is to propose an optimisation for avoiding such unnecessary copies.
  
-While this example may not highlight the significance of the copy cost, there are scenarios where it does matter, such as processing large data batches (e.g., ETL-like processes) or having more complex data manipulation functions. The reason for having a separate "main()" function in the example will become clear later in the proposal.+While this example may not highlight the significance of the copy cost, there are scenarios where it does matter, such as processing large data batches (e.g., Extract-Transform-Load processes) or having more complex data manipulation functions. The reason for having a separate "main()" function in the example will become clear later in the proposal.
  
 A similar case where this optimisation is beneficial is for variables which are passed to functions and then never used again the caller. A similar case where this optimisation is beneficial is for variables which are passed to functions and then never used again the caller.
rfc/implicit_move_optimisation.1684017974.txt.gz · Last modified: 2023/05/13 22:46 by nielsdos