Live data from Hacker News

Codon: A high-performance Python-like compiler using LLVM

github.com

181–184 of 184 posts

Re: Codon: A high-performance Python-like compiler using LLVM

#181
post #177

Earlier quoted context omitted.

Because mixing types in an array is stupid enough that I thought it might just not be valid.

Mixing types in an array/list is not remotely stupid. How exactly would you suggest expressing the lack of a value in a series of numbers without None/null? There's your mixed types. Don't let weird dogma get in the way of practicality.

That's an Optional[int]. It's not "mixed types", it's a union type.

Re: Codon: A high-performance Python-like compiler using LLVM

#182

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. This seems like a very different language from Python if it won't let you do: [1, 'a string']

With type hints you would model this as a Union type, i.e., Union[int, str]. This is perfectly legal with mypy and other Python type checkers.

Re: Codon: A high-performance Python-like compiler using LLVM

#183
post #138

Earlier quoted context omitted.

Wouldn't that exclude (most) nested lists?

What do you mean by nested lists? A list of lists, that's a list with a single type.

I was thinking more a tree-like structure, with lists or values.

Re: Codon: A high-performance Python-like compiler using LLVM

#184
post #177

Earlier quoted context omitted.

Mixing types in an array/list is not remotely stupid. How exactly would you suggest expressing the lack of a value in a series of numbers without None/null? There's your mixed types. Don't let weird dogma get in the way of practicality.

That's an Optional[int]. It's not "mixed types", it's a union type.

That is merely a detail of how the typing module has decided to set up convenient aliases. Treated by the language (and likely compilers) as different types.
Post reply on HN