Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Generate __init__ with converters inline. #80
Here's some more horror. :)
The gains are actually more than I expected.
I was actually a little weirded out, but the tests pass and playing around in the repl, it seems to work.
I thought the gains would be greatest with about 50% attributes with converters on them, but no, even with all attributes having converters, I see more than double the speed.
Current coverage is 100% (diff: 100%)
@@ master #80 diff @@ =================================== Files 8 8 Lines 398 413 +15 Methods 0 0 Messages 0 0 Branches 88 88 =================================== + Hits 398 413 +15 Misses 0 0 Partials 0 0
Not really sure comparing strings of source code will be a better test than testing the actual behavior. I guess we could assert that the generated init is the most optimal it can be, but we'd also have to take into account some internal stuff, like the __attr_validator_x and __attr_convert_x globals.