Is S4 method dispatch slow?
问题 My S4 class has a method that is called many times. I noticed that the execution time is much slower than it would be if a similar function was called independently. So I added a slot with type "function" to my class and used that function instead of the method. The example below shows two ways of doing this, and both of them run much faster than the corresponding method. Also, the example suggests that the lower speed of the method is not due to method having to retrieve data from the class,