Reported initially in rspatial/terra/issues/1440: terra (especially, but also other packages using modules) takes a lot of time to load. @mdsumner did an analysis and found this:
- Methods are analyzed twice, because the
initialize method is added after class creation, which triggers another full pass.
- Modules use reference classes. Using S4 in this context is much cheaper.
Full report and patches here. The patch for (1) doesn't change the behavior and is short and clear. The patch for (2) requires full revdep checks, but I wouldn't expect issues unless some package relies on modules being reference classes, which shouldn't. @mdsumner Would you mind sending the patches as PRs?
Reported initially in rspatial/terra/issues/1440:
terra(especially, but also other packages using modules) takes a lot of time to load. @mdsumner did an analysis and found this:initializemethod is added after class creation, which triggers another full pass.Full report and patches here. The patch for (1) doesn't change the behavior and is short and clear. The patch for (2) requires full revdep checks, but I wouldn't expect issues unless some package relies on modules being reference classes, which shouldn't. @mdsumner Would you mind sending the patches as PRs?