Main intention of bang! (performance "vs" memory "vs" mutation)

Im wondering what Julians mainly intend or promise when they offer a bang! version of a function:

  1. Less memory usage?
  2. Better runtime performance?
  3. In-place mutation? (my guess)

It feels like that most of the time all of three intentions are satisfied, but I’ve seen algorithms, where the in-place mutation prevents a better runtime performance. To assess those situations it would be great to have clarity on what to expect from the bang!

1 Like

Per the documentation, #3 is correct. It is an indication to the user that at least one of the arguments will be modified. #1 and #2 are often a consequence of in-place mutation (especially for larger objects) because new memory doesn’t have to be allocated (and later garbage collected).

7 Likes