Posts by DRMacIver@mastodon.social
(DIR) Post #Ac63WzZR95aMKdXxNQ by DRMacIver@mastodon.social
2023-11-23T11:30:09Z
0 likes, 0 repeats
@tante I never do. They seem like a good idea but don't play well with how I do talks.
(DIR) Post #Azdc186enV7ZmxTV20 by DRMacIver@mastodon.social
2025-10-27T14:44:17Z
1 likes, 0 repeats
@cfbolz Every time I learn more about how Python works I get a little sad, so I've mostly decided that it's best if I don't.
(DIR) Post #AzddRSjIqJmHEZfgWm by DRMacIver@mastodon.social
2025-10-27T15:07:45Z
0 likes, 0 repeats
@synlogic4242 @cfbolz I'm still mostly fond of Python, it's just that I'm the sort of fond that when people who know it less well ask me how something works I get a thousand yard stare and then tell them that knowing this information will not make them happy.
(DIR) Post #AzdiuaDkZNosdUcNUG by DRMacIver@mastodon.social
2025-10-27T15:33:51Z
0 likes, 0 repeats
While we're talking about weird Python edge cases, what do you think this does?```class Foo: def __getitem__(self, i): return i def __len__(self): return 5print(list(Foo()))```
(DIR) Post #Azdiuc0LwAI8AWMhsm by DRMacIver@mastodon.social
2025-10-27T15:35:06Z
0 likes, 0 repeats
The answer is so counter-intuitive to me that I have independently discovered it twice, about a year apart, and posted outraged comments about it in discord both times, and the second time had to be reminded that this was not the first time I'd discovered the behaviour.It's possible it's also not the first time I've posted it on mastodon.
(DIR) Post #Azdiue3yHgNGYK4cng by DRMacIver@mastodon.social
2025-10-27T15:42:30Z
0 likes, 0 repeats
@cfbolz Correct, yes. It will hang until it eventually runs out of memory.Now, do you know why?
(DIR) Post #AzdiugYB2LiyGaDm9w by DRMacIver@mastodon.social
2025-10-27T15:47:47Z
1 likes, 0 repeats
@cfbolz @tartley Yup, exactly that. Default iteration is like:```i = 0while True: try: yield x[i] except IndexError: break i += 1```Instead of:```for i in range(len(x)): yield x[i]```In some sense you should never be able to tell the difference in correct code, so you'll rarely notice this, but I've at least twice managed to write incorrect code that doesn't raise for out of bounds access
(DIR) Post #AzdizgA7uGgOVlLwi8 by DRMacIver@mastodon.social
2025-10-27T15:14:53Z
0 likes, 0 repeats
@cfbolz @synlogic4242 There are definitely a bunch of features that make me think that surely there was a better design available than this, but tbf I often can't suggest what that better design is.Descriptor protocol is my go to example here.But yeah often the design is complicated because there wasn't a simple way to do the desired thing under the necessary constraints and that was deemed worth it.
(DIR) Post #Azdj0an3Mj5w8hzpA0 by DRMacIver@mastodon.social
2025-10-27T15:32:17Z
1 likes, 0 repeats
@cfbolz @pozorvlak @synlogic4242 I definitely have not understood the descriptor protocol at a "knows the arbitrary corner cases" level tbh.
(DIR) Post #Aze0jTIblJzP9sk29w by DRMacIver@mastodon.social
2025-10-27T19:32:27Z
1 likes, 0 repeats
@dabeaz @pozorvlak @cfbolz @tartley I'm really enjoying the amount of Python developer trauma bonding that is occurring here today.
(DIR) Post #Aze0q1qgDkTw37nydM by DRMacIver@mastodon.social
2025-10-27T17:57:03Z
0 likes, 0 repeats
@cfbolz @dabeaz @tartley I knew NamedTuple was a function, so I was staring at this for a while trying to figure out how this could possibly work, and then decided maybe best if I just don't know.But goddammit now I'm curious again.
(DIR) Post #Aze0q4NMpBoht576rQ by DRMacIver@mastodon.social
2025-10-27T18:04:02Z
1 likes, 0 repeats
@cfbolz @dabeaz @tartley It appears that what's happening is that it calls `__mro_bases__()` on it.
(DIR) Post #Aze0q87usZpnWJupKi by DRMacIver@mastodon.social
2025-10-27T17:59:56Z
0 likes, 0 repeats
@cfbolz @dabeaz @tartley OK I've looked up just enough to know I don't want to know more.