JuliaData / DataFramesMeta.jl

Metaprogramming tools for DataFrames
https://juliadata.github.io/DataFramesMeta.jl/stable/
Other
479 stars 54 forks source link

Special-case `==` as with other one-argument functions #374

Open pdeffebach opened 8 months ago

pdeffebach commented 8 months ago

Similar to :A + :B, we can have :A == 1 become ==(1) I think.

bkamins commented 8 months ago

what difference does it make?

pdeffebach commented 8 months ago

It might lower compile time latency for first calling the expression, thats all

julia> @time transform(df, :a => ByRow(==(1)) => :c)
  0.000151 seconds (165 allocations: 9.984 KiB)
3×3 DataFrame
 Row │ a      b      c     
     │ Int64  Int64  Bool  
─────┼─────────────────────
   1 │     1      4   true
   2 │     2      5  false
   3 │     3      6  false

julia> @time transform(df, :a => ByRow(t -> t == 1) => :c)
  0.043623 seconds (45.06 k allocations: 3.008 MiB, 98.64% compilation time)
3×3 DataFrame
 Row │ a      b      c     
     │ Int64  Int64  Bool  
─────┼─────────────────────
   1 │     1      4   true
   2 │     2      5  false
   3 │     3      6  false