Repository navigation
Decimo v0.13.0
20260822 (v0.13.0)
Decimo v0.13.0 is a traits release. Numeric, Parsable and Rootable let code be written once and run over BigInt, BigUInt, BigDecimal, Decimal128 and BigFloat alike — a matrix library asking for T: Numeric & Rootable is the motivating case. BigInt gains /. The errors module is reworked so that the error kinds are functions returning a plain Error, which is a breaking change for code that spells a typed raise such as raises ValueError in its own signatures.
⭐️ New in v0.13.0
Traits (decimo.traits):
Numeric—zero(),one(),-x,+,-,*and/, conformed to byBigInt,BigDecimalandDecimal128. Enough for the whole of dense linear algebra. Every operation is declaredraises, the widest signature, so a non-raising implementation conforms unchanged (PR #265).Parsable— the staticfrom_string(), and the counterpart ofWritable: it lets a container be filled from a literal without knowing which number type it holds. Same three types (PR #266).Rootable—sqrt(), conformed to by five types,BigUIntandBigFloatincluded. It is separate fromNumericbecause those two can never beNumeric:BigUIntis unsigned and so has no__neg__, andBigFloatisMovablewithout beingCopyable. What the root means stays the implementing type's business — on an integral type it truncates, soBigInt("10").sqrt()is3, and a negative value raises on the four exact types but yieldsnanonBigFloat(PR #268).
Other additions:
BigInt.__truediv__—/on integers is closed and truncates toward zero, matching Mojo's ownInt:BInt(-7) / BInt(2)is-3whereBInt(-7) // BInt(2)is-4. The two operators differ exactly when the operands have opposite signs (PR #265).BigDecimal.zero()/one()andDecimal128.zero()/one(), theNumericspelling of the identities.Decimal128.ZERO()andONE()stay as they are (PR #265).PRECISION(28, the same default as Python'sdecimal) is exported from the top level, so a caller can name the default it is getting (PR #268).
🦋 Changed in v0.13.0
Errors (PR #267):
- The error kinds are now functions, not aliases for a parametrised payload type:
ValueError,OverflowErrorand the rest return a plainError, so an enclosing function needs nothing beyond a bareraises. Raise sites are unchanged, but a signature can no longer be spelledraises ValueError— a typed raise is invariant in Mojo v1.0.0, which cuts such a function off fromstd.testingand from any ordinary helper.BaseErroris now the payload only. - A new comptime toggle
_USE_COLOURblanks every ANSI escape, for when the tracebacks go to a log file rather than a terminal. Chained tracebacks gain a blank line after the separator, and a frame now names the function it was raised in.
Signatures (PR #268):
BigDecimal.sqrt()splits its defaultedprecisioninto the overloadssqrt(self)andsqrt(self, precision), since in Mojo a default argument does not satisfy a trait signature. Existing calls are unaffected.root()converges on one spelling,root(self, n: Int), whichBigDecimal,Decimal128andBigFloatnow all accept.BigDecimalkeeps itsBigDecimal-degree overloads for non-integral roots andBigFloatitsUInt32one. Every existing call keeps working.rootis deliberately not part ofRootable:BigIntandBigUInthave no nth root to offer.
Documentation and tooling:
- Markdown across the repository is reformatted — long lines rewrapped and list formatting made uniform — and
argmojois an active Pixi dependency again, pinned to>=0.8.0,<0.9.0now that modular-community ships it (PR #264). - The user manual's Appendix B documents the three traits and which types conform; the
BigIntdivision section covers the new/(PR #265, #266, #268). - The test suite
numericis renamed totraits, withnumericandnumkept as aliases and the tests moved totests/traits/(PR #266, #267). tests/test.shbug fix: the retry loop read$?after anif, which is theifstatement's own status — zero — so a suite that failed to compile was reported as passing. It now uses&&(PR #268).