Movatterモバイル変換
[0]ホーム
[Python-Dev] Function Hash: Check it in?
Tim Peterstim.one@home.com
Mon, 29 Jan 2001 16:51:56 -0500
[Moshe Zadka]> ...> I'm starting to wonder what the tests really test: the language> definition, or accidents of the implementation?You'd be amazed (appalled?) at how hard it is to separate them.In two previous lives as a Big Iron compiler hacker, we routinely had to getour compilers validated by a govt agency before any US govt account would beallowed to buy our stuff; e.g.,http://www.itl.nist.gov/div897/ctg/vpl/language.htmThis usually *started* as a two-day process, flying the inspector to ourheadquarters, taking perhaps 2 minutes of machine time to run the testsuite, then sitting around that day and into the next arguing about whetherthe "failures" were due to non-standard assumptions in the tests, orcompiler bugs. It was almost always the former, but sometimes that didn'tget fully resolved for months (if the inspector was being particularlytroublesome, it could require getting an Official Interpretation from therelevant stds body -- not swift!). (BTW, this is one reason huge customersare often very reluctant to move to a new release: the validation processcan be very expensive and drag on for months)>>> def f():... global g... g += 1... return g...>>> g = 0>>> d = {f(): f()}>>> d{2: 1}>>>The Python Lang Ref doesn't really say whether {2: 1} or {1: 2} "should be"the result, nor does it say it's implementation-defined. If you *asked*Guido what he thought it should do, he'd probably say {1: 2} (not much of aguess: I asked him in the past, and that's what he did say <wink>).Something "like that" can show up in the test suite, but buried under layersof obfuscating accidents. Nobody is likely to realize it in the absence ofa failure motivating people to search for it.Which is a trap: sometimes ours was the only compiler (of dozens anddozens) that had *ever* "failed" a particular test. This was most often thecase at Cray Research, which had bizarre (but exceedingly fast -- which iswhat Cray's customers valued most) floating-point arithmetic. I recall onetest in particular that failed because Cray's was the only box on earth thatset I to 1 in INTEGER I I = 6.0/3.0Fortran doesn't define that the result must be 2. But-- you guessedit --neither does Python.Cute: at KSR, INT(6.0/3.0) did return 2 -- but INT(98./49.) did not <wink>.then-again-the-python-test-suite-is-still-shallow-ly y'rs - tim
[8]ページ先頭