Movatterモバイル変換


[0]ホーム

URL:


Wayback Machine
29 captures
08 Dec 2022 - 20 Aug 2025
AprMAYJun
25
202220232024
success
fail
COLLECTED BY
Collection:Save Page Now
TIMESTAMPS
loading
The Wayback Machine - https://web.archive.org/web/20230525002540/https://docs.exaloop.io/codon/general/differences
Search
⌃K

Differences with Python

While Codon's syntax and semantics are nearly 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.
Please see ourroadmap for more information about how we plan to close some of these gaps in the future.

Data types

  • Integers: Codon'sint is a 64-bit signed integer, whereas Python's (after version 3) can be arbitrarily large. However Codon does support larger integers viaInt[N] whereN 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.
  • Tuples: Since tuples compile down to structs, tuple lengths must be known at compile time, meaning you can't convert an arbitrarily-sized list to a tuple, for instance.

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 bymath functions. Strict adherence to Python semantics can be achieved by using the-numerics=py flag of the Codon compiler. Note that this doesnot changeints 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 viafrom python import.
Copy link
On this page
Data types
Type checking
Numerics
Modules

[8]
ページ先頭

©2009-2025 Movatter.jp