Alyssa Coghlan@ancoghlan@mastodon.social
@elyn@tech.lgbt 님에게 답글

@elyn Python types:

"Everything's an object, right"

"OK, sure"

"So type, the type of types, is a subclass of object"

"OK, ..."

"And object, since it's a type, is an instance of type"

"... wat?"

(the amount of "lying to computers" involved in starting a Python interpreter is genuinely fun, for a given definition of "fun")

Alyssa Coghlan@ancoghlan@mastodon.social
@elyn@tech.lgbt 님에게 답글

@elyn Yeah, I advise folks to steer clear of the core type machinery implementation unless they actually *want* to stretch their brains into weird shapes in order to understand it. Lots of "this isn't quite true yet, but it will be true before it needs to be true, just trust us on that, computer".

I also love the fact that it is all completely *un*necessary knowledge for folks that just want to use Python without worrying about the fiddly details of how it works.

3 7

불러오는 중…

konsti@konstin@mastodon.social
@elyn@tech.lgbt 님에게 답글

@elyn @ancoghlan a lot of the python internal type machinery was added before python had spellable types, which now shows up as those strange breaks in the type math.

there's a similar case where `float` actually means `float | int`, so there's now no way of saying just float, no int, even though `isinstance(1, float) == False`.

Alyssa Coghlan@ancoghlan@mastodon.social
@konstin@mastodon.social 님에게 답글

@konstin @elyn Oof, I had managed to forget how much worse it all was before the classic class emulation bits were dropped, but that observation reminded me. I shudder to think how much harder it would have been to start defining type forms if those were still around (as you say, it's hard enough retrofitting a comprehensive description language to the status quo).