Skip to content

Conversation

@aderyabin
Copy link

Currently, typecasting works on attribute reading. There are two defects:
– every reading is every typecasting.
– if typecasted class has attributes they can't be changed, because typecasting creates a new instance every time.

I suggest typecasting on writing. It avoids from both defects

@film42
Copy link

film42 commented Feb 8, 2016

@aderyabin I think we should actually find a way to move away from creating a new instance of a type caster class because I've found it to add an enormous amount of overhead in object allocation. I started moving over to setting a :typecaster directly, because I found an order of magnitude in speed-up by not creating a new typecaster each time.

EDIT: I should have mentioned, I saw this performance bottleneck while running under a profiler (which is very costly in terms of allocations), but in real world MRI examples, it's about 10% faster (2 second reduction after 10k iterations of a model with 93 attributes).

@aderyabin
Copy link
Author

@film42 Could you please share benchmark script?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants