Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6380971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:20:08+00:00 2026-05-25T02:20:08+00:00

It is often stated that RPython (a subset of Python) is statically typed. (E.g.

  • 0

It is often stated that RPython (a subset of Python) is statically typed. (E.g. on Wikipedia.)

Initially, I wondered how they would add that to Python and thought that they might have added the requirement to add statements such as assert isinstance(arg1, ...) at the beginning of each function (but I couldn’t really believe that).

Then I looked at some RPython code and it doesn’t really look statically typed at all. In many cases, it might be that the compiler can prove that a function argument can only be of certain types but definitely not in all cases.

E.g., this is the RPython implementation of string.split:

def split(value, by, maxsplit=-1):
    bylen = len(by)
    if bylen == 0:
        raise ValueError("empty separator")

    res = []
    start = 0
    while maxsplit != 0:
        next = value.find(by, start)
        if next < 0:
            break
        res.append(value[start:next])
        start = next + bylen
        maxsplit -= 1   # NB. if it's already < 0, it stays < 0

    res.append(value[start:len(value)])
    return res

In the PyPy documentation about RPython, it is said: “variables should contain values of at most one type“.

So, do function arguments also count as variables? Or in what sense is RPython statically typed? Or is this actually misstated?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:20:09+00:00Added an answer on May 25, 2026 at 2:20 am

    So, do function arguments also count as variables?

    Of course they do. They always do in pretty much every language.

    Or in what sense is RPython statically typed? Or is this actually misstated?

    The statement is correct. RPython is not Python. Well, it’s a subset of it and can be run as Python code. But when you actually compile RPython code, so much dynamicness is taken away from you (albeit only after import time, so you can still use metaclasses, generate code from strings, etc. – used to great effect in some modules) that the compiler (which is not the Python compiler, but vastly different from traditional compilers; see associated documentation) can indeed decide types are used statically. More accurately, code that uses dynamicness makes it past the parser and everything, but results in a type error at some point.

    In many cases, it might be that the compiler can prove that a function argument can only be of certain types but definitely not in all cases.

    Of course not. There’s a lot of code that’s not statically typed, and quite some statically-typed code the current annotator can’t prove to be statically typed. But when such code is enountered, it’s a compilation errors, period.

    There are a few points that are important to realize:

    • Types are inferred, not stated explicitly (well, for the most part; I believe there are a few functions that need assertions to help the annotator). Static typing does not (as you seem to imply in a comment) mean that the type has to be written out (that’s called manifest typing), it means that each expression (that includes variables) has a single type that never changes.

    • All that analysis happens on a whole-program basis! One can’t infer a (non-generic) type for a function def add(a, b): return a + b (the arguments might ints, floats, strings, lists, etc.), but if the function is called with integer arguments (e.g. integer literals or variables that were previously inferred to contain integers), it is determined that a and b (and, by the type of +, the result of add) are integers too.

    • Not all code in the PyPy repository is RPython. For example, there are code generators (e.g. in rlib.parsing) that run at compile time and produce RPython code, but are not RPython (frequently with a "NOT_RPYTHON" docstring, by the way). Also, large parts of the standard library are written in full Python (mostly taken straight from CPython).

    There’s a lot of very interesting material on how the whole translation and typing actually works. For example, The RPython Toolchain describes the translation process in general, including type inference, and The RPython Typer describes the type system(s) used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It's often stated that super should be avoided in Python 2. I've found in
Question I often see it stated that rules should be avoided and triggers used
Often we need to add a non-nullable column to a table, and it is
Often time I need to add a control to a dialog after the dialog
Often, programmers write code that generates other code. (The technical term is metaprogramming ,
Often multiple applications share a large codebase of libraries that change often in development.
I ran into this quite often stated problem but even after looking up nearly
Often, people say that it is better to say s.Length == 0 instead of
I have a web application that our product owner has stated must respond within
When I'm programming, I often find myself writing functions that -should- (to be proper

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.