title: Efficiency of methods on case class versus companion object in Spark & Scala
body: <p>In Spark &amp; Scala, is it more efficient to put logical methods directly on a case class or into the companion object? For example:</p>
  
  <pre class="lang-scala prettyprint-override"><code>final case class RichInt(x: Int) {
      def isLarge: Boolean = x &gt; RichInt.largeInt
  }
  
  object RichInt {
      private val largeInt: Int = 5
  }
  </code></pre>
  
  <p>versus </p>
  
  <pre class="lang-scala prettyprint-override"><code>final case class SlimInt(x: Int) {}
  
  object SlimInt {
      private val largeInt: Int = 5
      def isLarge(slimInt: SlimInt) : Boolean = {
           slimInt.x &gt; largeInt
       }
  }
  </code></pre>
  
  <p>The methods are called differently (<code>SlimInt.isLarge(slimInt)</code> versus <code>richInt.isLarge</code>), with the latter probably being more intuitive, but is there a significant performance penalty for one pattern versus the other?</p>