Prothon vs. Python integers

M

Marcin 'Qrczak' Kowalczyk

I've agreed to adding longs. I'm thinking of only having longs.

It's more efficient if ints which fit in a machine word (or a machine word
minus one or two bits used for tagging them as ints) are represented as
such, rather than using a generic big int representation.

It doesn't mean they should be treated differently in the language.
It can be a hidden implementation detail, visible only for those who write
extensions in C.
 
M

Mark Hahn

Marcin said:
It's more efficient if ints which fit in a machine word (or a machine
word minus one or two bits used for tagging them as ints) are
represented as such, rather than using a generic big int
representation.

It doesn't mean they should be treated differently in the language.
It can be a hidden implementation detail, visible only for those who
write extensions in C.

I've already implemented the new ints in Prothon. They behave as normal
ints until an overflow occurs and then they are treated as a bigint. There
is no performance penalty at all because I have to check for overflow
anyway.

C extension coders see no difference unless they want to deal with bigints.
Macros provide access to the ints and if they ask for a normal size int that
is actually a bigint it just throws an excepton.
 
C

Calvin Spealman

Marcin said:
It's more efficient if ints which fit in a machine word (or a machine word
minus one or two bits used for tagging them as ints) are represented as
such, rather than using a generic big int representation.

Seems like it should be possible to implement big numbers in a way that
small numbers are nearly as, as, or more efficient than machine integers,
when you take into account the overflow checking needed for regular
integers in a language like python.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top