Skip to content

set a lower limit for size of literal unions we will do precise type inference of operations for #957

@carljm

Description

@carljm

For example, we know that if we add Literal[1, 2] to Literal[3], we get Literal[4, 5]. But in some cyclic scenarios, something like x += 1 can result in an ever-expanding union (until we hit the Salsa cycle limit). We currently set an overall limit of 100 on literal-unions size, which is lower than the 200 Salsa cycle limit, but this still means we can iterate 100 times before we converge -- that's a lot.

We don't want to decrease our overall literal-unions size limit any lower than 100 (in fact ideally we'd increase it -- people should be able to explicitly create large literal unions). But we should set a much lower limit on the size of literal unions we are willing to do literal-math on (and beyond that limit we should just fall back to e.g. int). I think a limit in the low double-digits would be reasonable here. This would also significantly reduce the amount of fixpoint iteration needed in cyclic cases before we converge.

(This should apply not just to literal ints, but also operations on literal strings and bytes, too.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePotential performance improvementset-theoretic typesunions, intersections and more

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions