4 ms·
Go's generic implementation (sadly) tries to reduce the amount of code it generates by generating code which dispatches to the concrete methods at runtime. The
by throwaway894345 4y ago
Go's generic implementation (sadly) tries to reduce the amount of code it generates by generating code which dispatches to the concrete methods at runtime. The rules for when this dispatch happens aren't easy to understand, and they're subject to change, so reasoning about performance (already hard) gets strictly harder. In some cases, generics might make code faster, and in others it may make code slower.