News for hackers. Stuff that matters.
Re:Faster CPython (2021) [pdf] by orf on Sunday January 23, 2022 @02:30PM (#30049549)
There are a few different classes of introspection. The first is commonly used builtins like “isinstance”, “callable”, “getattr/hasattr” etc.

The second is the inspect module that builds on that, allowing you to get the stack frames, inspect function signatures etc.

The third is trackbacks, which need the stack and themselves are introspectable.

The fourth is metaclasses (making dynamic classes at runtime).

These are heavily used in Python, and are optimisation barriers. For example PyPy (Python with a JIT) disables optimisations when “inspect” is imported or used anywhere in the call stack.

Re:Faster CPython (2021) [pdf] by funklute on Sunday January 23, 2022 @03:18PM (#30050045)
How many of these "levels" (not to confuse them with actual classes) exist in javascript? Only the first one?

(that said, I guess the fourth one (metaclasses) isn't a clear yes/no, since OO is very different in js)

Re:Faster CPython (2021) [pdf] by Jasper_ on Sunday January 23, 2022 @04:20PM (#30050539)
Hard to compare exactly with that classification, but JavaScript only has the first one, and arguably parts of the fourth one.

metaclasses isn't really a major optimization hazard, it effectively boils down to hijacking the "class" syntax to instead run some custom code. It's used by things like dataclasses and the Django ORM to use class syntax to make a little DSL.

Re:Faster CPython (2021) [pdf] by ericvsmith on Sunday January 23, 2022 @10:17PM (#30053329)
dataclasses do not use metaclasses (I’m the dataclasses author).
Re:Faster CPython (2021) [pdf] by Jasper_ on Sunday January 23, 2022 @10:36PM (#30053439)
Apologies, I must have been confusing it with some other Python syntax tricks I've seen. I don't write too much Python anymore..
Re:Faster CPython (2021) [pdf] by pjmlp on Sunday January 23, 2022 @04:22PM (#30050559)
Smalltalk JITs do just fine with introspection and certainty Python does not have some magic feature that Smalltalk lacks.
Re:Faster CPython (2021) [pdf] by orf on Sunday January 23, 2022 @04:29PM (#30050608)
Despite being a totally different language based around message passing with no control structures?

None of those are insurmountable, they merely make writing a JIT harder if you want to support them: it’s hard to inline a function call if the inclining can have a visible effect.

Re:Faster CPython (2021) [pdf] by pjmlp on Sunday January 23, 2022 @05:11PM (#30051018)
That is the whole point, it doesn't get more dynamic than that.
Re:Faster CPython (2021) [pdf] by orf on Sunday January 23, 2022 @05:15PM (#30051052)
I’d say the lack of control flow structures and message passing would make it far, far easier to JIT.
Re:Faster CPython (2021) [pdf] by pjmlp on Sunday January 23, 2022 @06:10PM (#30051593)
If that was the case, there would be no need for StrongTalk.
Re:Faster CPython (2021) [pdf] by orf on Sunday January 23, 2022 @06:14PM (#30051628)
Can you really not think of any other benefits?
Re:Faster CPython (2021) [pdf] by pjmlp on Sunday January 23, 2022 @06:30PM (#30051778)
I certainly can, and I can also think of several examples of dynamic languages that succeed where Python fails.

All of them just as dynamic, if not more.

Re:Faster CPython (2021) [pdf] by orf on Sunday January 23, 2022 @06:33PM (#30051801)
If you can think of other benefits to Strongtalk other than “it makes jit compiling better” then why say that there is no reason for it to exist if Smalltalk’s design makes it easy to JIT?
Re:Faster CPython (2021) [pdf] by pjmlp on Monday January 24, 2022 @01:35AM (#30054300)
Python is not even able to do the basic Smalltalk part, so it doesn't matter what StrongTalk brings into the picture.
Re:Faster CPython (2021) [pdf] by orf on Monday January 24, 2022 @06:05AM (#30056054)
Ok now we are on the same page about there being a need for Strongtalk other than “it may or may not JIT better” we will loop back a few comments and try again:

I’d say the lack of control flow structures and message passing would make it far, far easier to JIT.