Benefits of convtools¶
Fewer bugs & readability¶
- it forces you to split the definition of data conversion from the data itself
- functional approach (pipes, "everything is an expression") lifts the obligation to name variables at each step, lowering the chance of confusing them
convtoolstest coverage is 100% and its development is test-driven, so whenever a bug is found, we'll do our best to make sure it never occurs again.
DRY¶
In some cases, to keep the code DRY (complying with "Don't Repeat Yourself" principle) or just readable you need to pay with code performance:
- intensive code reuse (function call overhead)
- configs known at compile time (loops, which can be unrolled)
convtools encapsulates non-dry pieces in the code it generates.
Of course, there's also a cost, but it is completely under your control where
and when to run gen_converter to spend a fraction of a second to generate
an ad-hoc converter.
Functionality¶
Since convtools is a code-generating layer, it provides you with extra
functionality like group_by, joins, pipes, etc.
Performance¶
'The Art of Computer Programming' book by Donald Knuth:
The real problem is that programmers have spent far too much time worrying about efficiency in the wrong places and at the wrong times; premature optimization is the root of all evil (or at least most of it) in programming.
convtools worries about code efficiency, so you can put more effort into
other parts of your code. The below table provides the speed-up of
convtools-based solutions over the naive ones.
| name | 3.14 | 3.13 | 3.12 | 3.11 | 3.10 | 3.9 | 3.8 | 3.7 | 3.6 |
|---|---|---|---|---|---|---|---|---|---|
| GetDefaultPositive | +12.2% | +20.9% | +23.8% | +24.5% | +39.8% | +40.0% | +16.6% | +10.1% | +14.2% |
| IterOfIter1 | +32.4% | +22.0% | +95.7% | +117.1% | +104.9% | +80.3% | +85.7% | +85.2% | +106.2% |
| Aggregate1 | +42.3% | +29.6% | +58.0% | +66.4% | +60.8% | +50.6% | +76.2% | +74.7% | +72.6% |
| GroupBy1 - MANY_GROUPS | +46.0% | +38.5% | +34.2% | +39.2% | -8.5% | +3.2% | -4.7% | +1.5% | -3.6% |
| DatetimeFormat2 | +54.5% | +46.0% | +50.8% | +30.9% | +41.2% | +34.8% | +52.0% | +46.2% | +37.7% |
| DatetimeFormat1 | +62.8% | +73.9% | +72.0% | +52.4% | +60.2% | +59.2% | +72.7% | +66.1% | +55.1% |
| GroupBy1 - FEW_GROUPS | +82.4% | +59.6% | +64.6% | +78.3% | +6.3% | -1.7% | -9.0% | +1.3% | -4.9% |
| GetDefaultNegative | +84.2% | +76.1% | +96.1% | +232.3% | +155.6% | +154.1% | +6.5% | +3.8% | +3.1% |
| TableDictReader | +94.1% | +120.8% | +123.9% | +158.2% | +166.3% | +170.2% | +173.1% | +278.8% | +364.9% |
| DateFormat2 | +143.6% | +154.2% | +173.0% | +134.5% | +151.5% | +145.2% | +177.1% | +178.9% | +151.2% |
| DatetimeParse2 | +297.5% | +304.5% | +211.8% | +214.4% | +235.3% | +223.4% | +228.6% | +217.0% | +209.2% |
| DateParse2 | +342.2% | +335.0% | +276.0% | +268.1% | +296.2% | +260.6% | +272.1% | +266.0% | +257.2% |
| DateParse1 | +343.4% | +341.7% | +264.5% | +266.3% | +296.5% | +263.9% | +262.4% | +262.0% | +259.2% |
| DatetimeParse1 | +351.7% | +337.0% | +247.1% | +251.7% | +280.3% | +265.7% | +269.8% | +258.2% | +259.6% |
| DateFormat1 | +476.8% | +505.2% | +553.2% | +496.1% | +496.4% | +470.3% | +492.0% | +449.2% | +418.1% |
In cases where there are multiple speed test results, the worst is taken. See benchmarks on Github for source code.