Hi,
Le 27/07/2019 à 21:04, Wes McKinney a écrit : > * My understanding is that the PIMPL pattern will perform better for > non-virtual functions that are called a lot. It'd be helpful to know > the magnitude of the performance difference Modern CPUs have indirect branch predictors. If an indirect branch (e.g. virtual function call) always resolves to the same target address, it should have very good performance. My main issue with the Pimpl pattern is the amount of boilerplate it requires. One workaround is to use a "half-pimpl", i.e. keep public API implementations in the main class, but put private helpers in the pimpl. See e.g. MockFileSystem vs. MockFileSystem::Impl here: https://github.com/apache/arrow/blob/master/cpp/src/arrow/filesystem/mockfs.cc#L217 That's not always convenient though. Regards Antoine. > * Complex inheritance patterns may require use of virtual inheritance, > which can create a burden for downstream users (e.g. they may have to > use dynamic_cast to convert between types in the class hierarchy) > > I'm far from a C++ expert so I'm always learning as time goes on, but > hopefully other C++ developers have thoughts about this and we can > keep an eye out in code reviews for cases where a simpler > implementation may suffice > > - Wes >