1
0
mirror of https://github.com/exaloop/codon.git synced 2025-06-03 15:03:52 +08:00
codon/docs/intro/differences.md
A. R. Shajii bac6ae58dd
Generator argument optimization (and more) (#175)
* Fix ABI incompatibilities

* Fix codon-jit on macOS

* Fix scoping bugs

* Fix .codon detection

* Handle static arguments in magic methods; Update simd; Fix misc. bugs

* Avoid partial calls with generators

* clang-format

* Add generator-argument optimization

* Fix typo

* Fix omp test

* Make sure sum() does not call __iadd__

* Clarify difference in docs

* Fix any/all generator pass

* Fix  InstantiateExpr simplification; Support .py as module extension

* clang-format

* Bump version

Co-authored-by: Ibrahim Numanagić <ibrahimpasa@gmail.com>
2023-01-17 10:21:59 -05:00

47 lines
1.7 KiB
Markdown

While Codon's syntax and semantics are virtually identical
to Python's, there are some notable differences that are
worth mentioning. Most of these design decisions were made
with the trade-off between performance and Python compatibility
in mind.
# Data types
- **Integers:** Codon's `int` is a 64-bit signed integer,
whereas Python's (after version 3) can be arbitrarily large.
However Codon does support larger integers via `Int[N]` where
`N` is the bit width.
- **Strings:** Codon currently uses ASCII strings unlike
Python's unicode strings.
- **Dictionaries:** Codon's dictionary type does not preserve
insertion order, unlike Python's as of 3.6.
# Type checking
Since Codon performs static type checking ahead of time, a
few of Python's dynamic features are disallowed. For example,
monkey patching classes at runtime (although Codon supports a
form of this at compile time) or adding objects of different
types to a collection.
These few restrictions are ultimately what allow Codon to
compile to native code without any runtime performance overhead.
Future versions of Codon will lift some of these restrictions
by the introduction of e.g. implicit union types.
# Numerics
For performance reasons, some numeric operations use C semantics
rather than Python semantics. This includes, for example, raising
an exception when dividing by zero, or other checks done by `math`
functions. Strict adherence to Python semantics can be achieved by
using the `-numerics=py` flag of the Codon compiler. Note that this
does *not* change `int`s from 64-bit.
# Modules
While most of the commonly used builtin modules have Codon-native
implementations, a few are not yet implemented. However these can
still be used within Codon via `from python import`.