From 7125aaf6b61376df1cd5d0a13575882d159a486e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gilles?= <sebastien.gilles@inria.fr> Date: Mon, 10 May 2021 17:31:57 +0200 Subject: [PATCH] Reword a bit the new paragraph about STL and performance. --- 5-UsefulConceptsAndSTL/7-Algorithms.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/5-UsefulConceptsAndSTL/7-Algorithms.ipynb b/5-UsefulConceptsAndSTL/7-Algorithms.ipynb index 4afcd0e..2a183d1 100644 --- a/5-UsefulConceptsAndSTL/7-Algorithms.ipynb +++ b/5-UsefulConceptsAndSTL/7-Algorithms.ipynb @@ -539,9 +539,9 @@ "\n", "The reading of \\cite{Cukic2018} should provide more incentive to use them.\n", "\n", - "It is important also to highlight that the STL algorithms may be more efficient that any development that may do, but these algorithms are designed in a very generic way, so these methods can be applied to any class in C++. Therefore. the reason for using the standard library algorithms is not to get better efficiency, it is to allow you to think at a higher level of abstraction. While there might be some cases where the algorithm will be faster than your own hand-rolled code, that's not what they're there for. One of the great advantages of C++ is that it allows you to bypass the built-in libraries when you have a specific need. If your benchmarking has shown that the standard library is causing a critical slowdown, you are free to explore classic alternatives such as loop unrolling. For most purposes that will never be necessary.\n", + "It is also important also to highlight that while the STL algorithms may provide you efficiency (this library is written by highly skilled engineers after all), this is not its main draw: the algorithms are written to be as generic as possible. The primary reason to use them is to allow you to think at a higher level of abstraction, not to get the fastest possible implementation. So if your ~~intuition~~ benchmarking has shown that the standard library is causing a critical slowdown, you are free to explore classic alternatives such as loop unrolling - that's one of the strength of the language (and the STL itself opens up this possibility directly for some of its construct - you may for instance use your own memory allocator when defining a container). For most purposes however that will not be necessary.\n", "\n", - "On top of this, C++ 20 introduce a completely new way to deal with algorithms, which does not rely on direct use of iterators but instead on a range library. This leads to a syntax which is more akin to what is done in other languages - see for instance this example lifted from this [blog post](https://www.modernescpp.com/index.php/c-20-the-ranges-library):\n" + "FYI, C++ 20 introduce a completely new way to deal with algorithms, which does not rely on direct use of iterators but instead on a range library. This leads to a syntax which is more akin to what is done in other languages - see for instance this example lifted from this [blog post](https://www.modernescpp.com/index.php/c-20-the-ranges-library):\n" ] }, { @@ -646,5 +646,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } -- GitLab