whitequark changed the topic of #amaranth-lang to: Amaranth hardware definition language · weekly meetings on Mondays at 1700 UTC · code https://github.com/amaranth-lang · logs https://libera.irclog.whitequark.org/amaranth-lang
<mwk> alright I managed to reproduce it locally with py 3.8
<mwk> s_push: parser stack overflow
<mwk> huh
<mwk> you've... hit the Python 3.8 limit of 1700 entries on parsing stack
<mwk> and Python 3.9 as well, for that matter
<mwk> oh the error message is also in the CI, just buried in the logs
<mwk> Python 3.10 and up are fine due to having a completely new parser (see https://peps.python.org/pep-0617/)
<charlottia> huh. And sure enough, the change from `self` to `mask` in those binary operands makes the difference, because of adding the extra layer of `(mask & _)` enough times.
<mwk> so: the CRC module makes a deeply nested amaranth HDL expression; pysim directly translates it to Python, multiplying the nesting level by some small constant due to the masking, you end up overflowing the fixed-size Python parser stack
<mwk> the limit is Python-compile-time constant and non-configurable btw
<mwk> and I mean cpython-compile-time
<whitequark> yea it's not the first time we hit that
<charlottia> indeed. The xor branch alone returns chunks of Python many thousands of bytes long in this case (which are then included in others).
<whitequark> but it usually was due to very large Array expressions in memories
<whitequark> the fix is simple, add intermediate temporaries for expressions that are more than like, 1k long
<whitequark> we have the infra for it iirc?
<charlottia> hrmmm. The value compiler descends fairly directly through its operands..
<whitequark> I don't entirely remember it yea >_>
<charlottia> oh, yeah, just self.emitter.def_var/gen_var.
<whitequark> yep
<charlottia> can confirm the most brainless test impl of that does fix.
<whitequark> perfect!
<adamgreig[m]> aah, I was testing locally on py3.10 and the CI was bombing out on 3.8 and so cancelling the >3.8 runs so we never saw them succeed
<adamgreig[m]> shame as it would have been a bit more obvious if 3.8 was/3.9 was failing and 3.10 worked
<charlottia> as a basis.
<charlottia> adamgreig[m]: And this is a really good point!
<charlottia> Catherine: want me to open a PR for a fix like the above? Or should adamgreig incorporate in his branch?
<whitequark> former please!
<charlottia> 'kay!
xiretza[m] has quit [Server closed connection]
xiretza[m] has joined #amaranth-lang
<_whitenotifier-6> [YoWASP/yosys] whitequark pushed 1 commit to develop [+0/-0/±2] https://github.com/YoWASP/yosys/compare/01554ac38448...7006ebfedf33
<_whitenotifier-6> [YoWASP/yosys] whitequark 7006ebf - Update dependencies.
<charlottia> PR incoming, just had to reduce a nice-enough test!
<_whitenotifier-6> [amaranth] charlottia opened pull request #828: sim._pyrtl: don't blow parser stack on older Pythons. - https://github.com/amaranth-lang/amaranth/pull/828
<_whitenotifier-6> [amaranth] codecov[bot] commented on pull request #828: sim._pyrtl: don't blow parser stack on older Pythons. - https://github.com/amaranth-lang/amaranth/pull/828#issuecomment-1612302041
<charlottia> (Also can confirm crc tests pass on 3.8 after rebase.)
<_whitenotifier-6> [amaranth-lang/amaranth] github-merge-queue[bot] pushed 2 commits to gh-readonly-queue/main/pr-828-b77e33f16a9c922810e84cf61c4c2cb641a95a2d [+0/-0/±2] https://github.com/amaranth-lang/amaranth/compare/10d7fd62cf36...60c2a1b4b86f
<_whitenotifier-6> [amaranth-lang/amaranth] charlottia fd4e25d - test_sim: failing test case.
<_whitenotifier-6> [amaranth-lang/amaranth] charlottia 60c2a1b - sim._pyrtl: don't blow parser stack on older Pythons.
<_whitenotifier-6> [amaranth-lang/amaranth] github-merge-queue[bot] pushed 2 commits to main [+0/-0/±2] https://github.com/amaranth-lang/amaranth/compare/b77e33f16a9c...60c2a1b4b86f
<_whitenotifier-6> [amaranth-lang/amaranth] charlottia fd4e25d - test_sim: failing test case.
<_whitenotifier-6> [amaranth-lang/amaranth] charlottia 60c2a1b - sim._pyrtl: don't blow parser stack on older Pythons.
<_whitenotifier-6> [amaranth-lang/amaranth] A deploy key deleted branch gh-readonly-queue/main/pr-828-b77e33f16a9c922810e84cf61c4c2cb641a95a2d
<_whitenotifier-6> [amaranth] whitequark closed pull request #828: sim._pyrtl: don't blow parser stack on older Pythons. - https://github.com/amaranth-lang/amaranth/pull/828
<_whitenotifier-6> [amaranth] whitequark deleted branch gh-readonly-queue/main/pr-828-b77e33f16a9c922810e84cf61c4c2cb641a95a2d - https://github.com/amaranth-lang/amaranth
<_whitenotifier-6> [amaranth-lang/amaranth-lang.github.io] whitequark pushed 1 commit to main [+0/-0/±28] https://github.com/amaranth-lang/amaranth-lang.github.io/compare/0ab7c21dd7db...8314b0ba25cd
<_whitenotifier-6> [amaranth-lang/amaranth-lang.github.io] github-merge-queue[bot] 8314b0b - Deploying to main from @ amaranth-lang/amaranth@60c2a1b4b86fe20601dd910a9699f1718838e7f0 🚀
<adamgreig[m]> whitequark: rebased onto the new main and looks like tests are passing. thanks charlotte!
<charlottia> Yay, glad!
whitequark has quit [Server closed connection]
whitequark has joined #amaranth-lang
tannewt_ has quit [*.net *.split]
alanvgreen has quit [*.net *.split]
Lord_Nightmare has quit [*.net *.split]
pie_ has quit [*.net *.split]
oter has quit [*.net *.split]
Lord_Nightmare has joined #amaranth-lang
<_whitenotifier-6> [amaranth-lang/amaranth] github-merge-queue[bot] pushed 1 commit to gh-readonly-queue/main/pr-681-60c2a1b4b86fe20601dd910a9699f1718838e7f0 [+5/-0/±2] https://github.com/amaranth-lang/amaranth/compare/a49ab04ba477...45b973078656
<_whitenotifier-6> [amaranth-lang/amaranth] adamgreig 45b9730 - Implement RFC 6: CRC Generator
alanvgreen has joined #amaranth-lang
tannewt_ has joined #amaranth-lang
pie_ has joined #amaranth-lang
oter has joined #amaranth-lang
<_whitenotifier-6> [amaranth-lang/amaranth] github-merge-queue[bot] pushed 1 commit to main [+5/-0/±2] https://github.com/amaranth-lang/amaranth/compare/60c2a1b4b86f...45b973078656
<_whitenotifier-6> [amaranth-lang/amaranth] adamgreig 45b9730 - Implement RFC 6: CRC Generator
<_whitenotifier-6> [amaranth-lang/amaranth] A deploy key deleted branch gh-readonly-queue/main/pr-681-60c2a1b4b86fe20601dd910a9699f1718838e7f0
<_whitenotifier-6> [amaranth] whitequark closed pull request #681: Add CRC generator - https://github.com/amaranth-lang/amaranth/pull/681
<_whitenotifier-6> [amaranth] whitequark deleted branch gh-readonly-queue/main/pr-681-60c2a1b4b86fe20601dd910a9699f1718838e7f0 - https://github.com/amaranth-lang/amaranth
<_whitenotifier-6> [amaranth-lang/amaranth-lang.github.io] whitequark pushed 1 commit to main [+8/-0/±35] https://github.com/amaranth-lang/amaranth-lang.github.io/compare/8314b0ba25cd...14e57dfb1f43
<_whitenotifier-6> [amaranth-lang/amaranth-lang.github.io] github-merge-queue[bot] 14e57df - Deploying to main from @ amaranth-lang/amaranth@45b9730786560893e7cc8eefa3409911be811d15 🚀
Degi_ has joined #amaranth-lang
Degi has quit [Ping timeout: 252 seconds]
Degi_ is now known as Degi
croedv has joined #amaranth-lang
elle has quit [Remote host closed the connection]
elle has joined #amaranth-lang
croedv is now known as peizled
crzwdjk has quit [Quit: Client closed]
peizled is now known as skiidc
skiidc has quit [Remote host closed the connection]
<_whitenotifier-6> [amaranth] charlottia opened pull request #829: lib.enum: allow `import * from amaranth.lib.enum`. - https://github.com/amaranth-lang/amaranth/pull/829
<_whitenotifier-6> [amaranth] codecov[bot] commented on pull request #829: lib.enum: allow `import * from amaranth.lib.enum`. - https://github.com/amaranth-lang/amaranth/pull/829#issuecomment-1612392356
<_whitenotifier-6> [amaranth-lang/amaranth] github-merge-queue[bot] pushed 1 commit to gh-readonly-queue/main/pr-829-45b9730786560893e7cc8eefa3409911be811d15 [+0/-0/±1] https://github.com/amaranth-lang/amaranth/compare/2db914f755d1...cdf8fcc32ffc
<_whitenotifier-6> [amaranth-lang/amaranth] charlottia cdf8fcc - lib.enum: allow `import * from amaranth.lib.enum`.
<_whitenotifier-6> [amaranth-lang/amaranth] github-merge-queue[bot] pushed 1 commit to main [+0/-0/±1] https://github.com/amaranth-lang/amaranth/compare/45b973078656...cdf8fcc32ffc
<_whitenotifier-6> [amaranth-lang/amaranth] charlottia cdf8fcc - lib.enum: allow `import * from amaranth.lib.enum`.
<_whitenotifier-6> [amaranth-lang/amaranth] A deploy key deleted branch gh-readonly-queue/main/pr-829-45b9730786560893e7cc8eefa3409911be811d15
<_whitenotifier-6> [amaranth] whitequark closed pull request #829: lib.enum: allow `import * from amaranth.lib.enum`. - https://github.com/amaranth-lang/amaranth/pull/829
<_whitenotifier-6> [amaranth] whitequark deleted branch gh-readonly-queue/main/pr-829-45b9730786560893e7cc8eefa3409911be811d15 - https://github.com/amaranth-lang/amaranth
<_whitenotifier-6> [amaranth-lang/amaranth-lang.github.io] whitequark pushed 1 commit to main [+0/-0/±30] https://github.com/amaranth-lang/amaranth-lang.github.io/compare/14e57dfb1f43...a5e26977753c
<_whitenotifier-6> [amaranth-lang/amaranth-lang.github.io] github-merge-queue[bot] a5e2697 - Deploying to main from @ amaranth-lang/amaranth@cdf8fcc32ffc8bab7aaf01d9def893ced368e376 🚀
<_whitenotifier-6> [amaranth] charlottia opened pull request #830: hdl.ast: implement ShapeCastable.__subclasshook__. - https://github.com/amaranth-lang/amaranth/pull/830
<galibert[m]> Oh, you people who know everything about python (or close enough), is there a way to know if I can call super() on a given object?
<galibert[m]> Technically I want to walk the whole (single) inheritance chain
<whitequark> mro?
<whitequark> * __mro__?
<galibert[m]> sounds like a cat purring
<galibert[m]> sounds related to my interests too, lemme try it
<galibert[m]> hmmm, looks like I can't call super() externally anyway, now that's annoying
<galibert[m]> mro() definitely helps though, thanks Catherine
<galibert[m]> ok, there's just too much I don't understand inthe python class/type system
<galibert[m]> I want to call a load method at every level of the inheritance hierarchy of a given object in order from top to bottom (doing stuff between each load, so super().load(...) in the method is not good enough). It looks way more complicated that I would have expected
<galibert[m]> s/that/than/
_whitelogger has joined #amaranth-lang
mindw0rk has quit [Ping timeout: 240 seconds]
mindw0rk has joined #amaranth-lang
<mwk> please don't use `__names__` that start and end with two underscores, those are reserved for definition by the Python language itself
mindw0rk has quit [Quit: ZNC 1.8.2 - https://znc.in]
mindw0rk has joined #amaranth-lang
<mwk> (as in, the Python language gets to define arbitrary magic semantics for such names, and you should only use these names as defined by these semantics)
<Psentee> I've seen a pattern of using `_names_` surrounded with single underscores for "userland magic", it's similar enough to be readable and still distinct from reserved `__magic__`
jjsuperpower has joined #amaranth-lang
<galibert[m]> Yeah, not sure why I did that in the first place, it makes no sense, I'll change it
<galibert[m]> changed here and in the real code :-)
<mwk> also may I recommend `for t in type(obj).mro()[-2::-1]:`
<galibert[m]> cute, didn't know that syntax
<_whitenotifier-6> [amaranth] whitequark reviewed pull request #830 commit - https://github.com/amaranth-lang/amaranth/pull/830#discussion_r1247023585
<_whitenotifier-6> [amaranth] whitequark reviewed pull request #830 commit - https://github.com/amaranth-lang/amaranth/pull/830#discussion_r1247024957
<_whitenotifier-6> [amaranth] whitequark commented on pull request #830: hdl.ast: implement ShapeCastable.__subclasshook__. - https://github.com/amaranth-lang/amaranth/pull/830#issuecomment-1613690529
<whitequark> <mwk> "also may I recommend `for t in..." <- charlotte: I think your PR could use `ShapeCastable in type(obj).mro()`? It's still *weird* but it's slightly less weird to explain to people that they'll have to use it...
<galibert[m]> errr, the discussion with mwk had nothing to do with amaranth (sorry, btw)
<galibert[m]> (it had to do with RE-ing the cyclone V fwiw)
<galibert[m]> oh, amusing
<galibert[m]> really didn't expect that, cool
<charlottia> <whitequark> "charlotte: I think your PR could..." <- ahhh, TIL, yes! Thanks and thanks mwk !