havenwood changed the topic of #ruby to: Ruby 3.3.3, 3.2.4, 3.4.0-preview1 https://www.ruby-lang.org | Logs https://libera.irclog.whitequark.org/ruby
weaksauce has quit [Quit: Textual IRC Client: www.textualapp.com]
jenrzzz has quit [Ping timeout: 256 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
Inline has quit [Remote host closed the connection]
Inline has joined #ruby
inline-_ has joined #ruby
Inline has quit [Ping timeout: 264 seconds]
vigumnov has quit [Ping timeout: 256 seconds]
victori has joined #ruby
fercell_ has joined #ruby
fercell has quit [Ping timeout: 264 seconds]
donofrio_ has joined #ruby
cappy has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
sam113101 has quit [Remote host closed the connection]
xdminsy has quit [Quit: Konversation terminated!]
sam113101 has joined #ruby
konsolebox has quit [Ping timeout: 252 seconds]
MomosOrDeath576 has joined #ruby
MomosOrDeath57 has quit [Ping timeout: 260 seconds]
MomosOrDeath576 is now known as MomosOrDeath57
sam113101 has quit [Remote host closed the connection]
sam113101 has joined #ruby
xdminsy has joined #ruby
cappy has quit [Quit: Leaving]
jenrzzz has joined #ruby
passbe has quit [Remote host closed the connection]
passbe has joined #ruby
grenierm has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
sphex has quit [Ping timeout: 268 seconds]
jenrzzz has joined #ruby
konsolebox has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
mrldlani has joined #ruby
mrldlani has quit [Remote host closed the connection]
jenrzzz has joined #ruby
axsuul has quit [Quit: 👋]
axsuul has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
rvalue has quit [Ping timeout: 264 seconds]
rvalue has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
weaksauce has joined #ruby
Linux_Kerio has joined #ruby
inline-_ has quit [Quit: Leaving]
Inline has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
Inline has quit [Remote host closed the connection]
Inline has joined #ruby
TomyWork has joined #ruby
TomyWork has quit [Remote host closed the connection]
TomyWork has joined #ruby
TomyWork has quit [Remote host closed the connection]
MomosOrDeath57 has quit [Ping timeout: 272 seconds]
TomyWork has joined #ruby
cappy has joined #ruby
jenrzzz has joined #ruby
donofrio_ has quit [Remote host closed the connection]
jenrzzz has quit [Ping timeout: 268 seconds]
grenierm has quit [Ping timeout: 250 seconds]
TomyWork has quit [Ping timeout: 272 seconds]
TomyWork has joined #ruby
mmohammadi9812 has joined #ruby
TomyLobo has joined #ruby
peder has quit [Remote host closed the connection]
peder has joined #ruby
jenrzzz has joined #ruby
peder_ has joined #ruby
peder_ has quit [Remote host closed the connection]
peder has quit [Ping timeout: 246 seconds]
jenrzzz has quit [Ping timeout: 246 seconds]
peder has joined #ruby
Pixi has quit [Ping timeout: 252 seconds]
mmohammadi9812 has quit [Ping timeout: 268 seconds]
peder_ has joined #ruby
peder_ has quit [Quit: leaving]
Pixi has joined #ruby
peder has quit [Quit: leaving]
sphex has joined #ruby
peder has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
Pixi` has joined #ruby
Pixi` has quit [Read error: Connection reset by peer]
Pixi` has joined #ruby
Pixi has quit [Ping timeout: 260 seconds]
Pixi__ has joined #ruby
Pixi` has quit [Ping timeout: 252 seconds]
graywolf has joined #ruby
cappy has quit [Quit: Leaving]
eddof13 has joined #ruby
mange has quit [Remote host closed the connection]
eddof13 has quit [Quit: eddof13]
donofrio has joined #ruby
FetidToot34 has joined #ruby
FetidToot3 has quit [Ping timeout: 268 seconds]
FetidToot34 is now known as FetidToot3
eddof13 has joined #ruby
mmohammadi9812 has joined #ruby
user71 has joined #ruby
Pixi__ has quit [Quit: Leaving]
jenrzzz has joined #ruby
eddof13 has quit [Quit: eddof13]
jenrzzz has quit [Ping timeout: 264 seconds]
Pixi has joined #ruby
TomyWork has quit [Remote host closed the connection]
eddof13 has joined #ruby
TomyLobo has quit [Ping timeout: 256 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 264 seconds]
mmohammadi9812 has quit [Ping timeout: 260 seconds]
Astra67 has joined #ruby
Astra67 is now known as Astra1993
konsolebox has quit [Quit: .]
<Astra1993> hello everyone
<Astra1993> I was reading an article regarding ruby's Struct
<Astra1993> under the Benchmarks section
<Astra1993> something struck me as very odd
<Astra1993> Multiple struct-like structures are defined using different available Ruby constructs (Array, Hash, Struct, Data, Class, OpenStruct)
<Astra1993> and then the performance of their instantiation is measured
<Astra1993> my question is why instantiating a class is five-folds slower than instantiating the same structure with a Hash?
<Astra1993> *three-folds
<Astra1993> and if the reason is because the class is defined inside of the Ruby code, and the Hash is a native object defined in C, then why Struct (which afaik is also a native construct) is also slower than Hash?
jenrzzz has joined #ruby
<kinduff> because when you initialize a class you also initialize the object's instance variables, setup the inheritance chain and method table, etc
<kinduff> Hashes are implemented in C, yes, but its a simple datastructure
<Astra1993> But everything is an Object in Ruby
<kinduff> and Structs are also implemented in C btw
<Astra1993> Ruby has to instantiate an object whether it is instantiating a Hash or a Struct
<kinduff> yes, but there are differences due to the specifics of how different objects are instantiated and managed internally
<Astra1993> I personally benchmarked reading attributes from a Class object and dereferencing keys from a Hash object, and the performance was the same (#bmbm with GC disabled beforehand)
Inline has quit [Remote host closed the connection]
<Astra1993> I was naturally expecting the Class object to be faster (I don't know why, gut feeling I guess) than the Hash
<kinduff> I doubt that the performance was the same
Inline has joined #ruby
<Astra1993> Where can I post code? Can I send it here?
jenrzzz has quit [Ping timeout: 252 seconds]
<kinduff> no, use gist
<kinduff> or pastebin
<kinduff> is this similar to what you tested?
<Astra1993> You're testing instantiation. That's faster with a Hash, by a magnitude of two, on my machine as well. I just tested reading attributes. Let me send the code in a pastebin
<kinduff> Alright
<kinduff> attr_accessor is pretty optimized
<ruby[bot]> Astra1993: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com or https://dpaste.org/
<kinduff> Still slower Astra
<kinduff> I posted the results in my gist. I'm running 3.2.2 tho, what version are you running?
<Astra1993> 3.0.2p107
<Astra1993> It is slower. but being slower by 1.01x is not as noticable
<Astra1993> as the instantiation being 2 to 3 times slower
<kinduff> because of attr_accessor
jenrzzz has joined #ruby
<Astra1993> I thought attr_accessor was better from a performance perspective than defining a getter in Ruby code
<Astra1993> (Thanks for the link btw! I'll read it now)
<kinduff> It is!
<Astra1993> :|
<kinduff> Your benchmark shows almost 2x slower if attr_accessor is removed
<kinduff> and defining a getter ofc
<Astra1993> Absolutely. I have no contention there
<Astra1993> What's bothering me is why a Struct isn't as fast as a Hash?!
<Astra1993> They are both native objects
<kinduff> doesnt matter if its native or not, what you are doing with a Struct is very different from a Hash
<kinduff> You add n keys on initialization to a hash, but you need to define them before in a Struct
<kinduff> this gives a hint of why performance is better, since the hash keys are defined, are set in memory, so its optimal
<kinduff> rather than storing in memory a whole hash which can be dynamic, variable, etc
<kinduff> this is what I think, I may be wrong (certainly I am haha)
eddof13 has quit [Quit: eddof13]
jenrzzz has quit [Ping timeout: 268 seconds]
jenrzzz has joined #ruby
<Astra1993> You're correct, but the attributes are also defined beforehand as well (when the Struct is first defined). It is definitely an implementation detail of Ruby's engine.
<Astra1993> Anyways, thanks a lot for your answer kinduff. <3
<Astra1993> Also why was Data created?? Its feature-set could've been easily added to Struct, by adding an `immutable' keyword argument to Struct.new
<Astra1993> I used to do immutable Structs by overriding #initialize and adding a freeze at the end: https://dpaste.org/eYeHq
cxl_ has quit [Quit: bye]
<Astra1993> Type multiplicity is how languages become Java! :D
jenrzzz has quit [Ping timeout: 240 seconds]
Linux_Kerio has quit [Ping timeout: 260 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
mmohammadi9812 has joined #ruby
TomyLobo has joined #ruby
Astra1993 has quit [Quit: Client closed]
Astra7 has joined #ruby
entropie has quit [Quit: ""]
Astra7 is now known as Astra1993
entropie has joined #ruby
Astra1993 has quit [Ping timeout: 250 seconds]
eddof13 has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
jenrzzz has joined #ruby
Astra71 has joined #ruby
Astra71 is now known as Astra1993
entropie has quit [Ping timeout: 260 seconds]
entropie has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
<kinduff> np Astra1993 :) was a fun chat
Vonter has quit [Ping timeout: 256 seconds]
Vonter has joined #ruby
eddof13 has quit [Quit: eddof13]
cappy has joined #ruby
eddof13 has joined #ruby
eddof13 has quit [Client Quit]
donofrio has quit [Read error: Connection reset by peer]
donofrio has joined #ruby
donofrio has quit [Remote host closed the connection]
donofrio has joined #ruby
donofrio has quit [Remote host closed the connection]
donofrio has joined #ruby
jenrzzz has joined #ruby
Astra1993 has quit [Ping timeout: 250 seconds]
user71 has quit [Quit: Leaving]
eddof13 has joined #ruby
mmohammadi9812 has quit [Ping timeout: 255 seconds]
weaksauce has quit [Quit: Textual IRC Client: www.textualapp.com]
graywolf has quit [Quit: WeeChat 4.3.0]
weaksauce has joined #ruby
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
cappy has quit [Quit: Leaving]
eddof13 has quit [Quit: eddof13]
Astra1993 has joined #ruby
Astra1993 has quit [Client Quit]
TomyLobo has quit [Read error: Connection reset by peer]
eddof13 has joined #ruby
mange has joined #ruby
eddof13 has quit [Quit: eddof13]
eddof13 has joined #ruby
eddof13 has quit [Client Quit]
victori has quit [Quit: ZNC 1.9.0 - https://znc.in]
victori has joined #ruby
victori has quit [Quit: ZNC 1.9.0 - https://znc.in]
victori has joined #ruby