Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Get rid of getPhases#272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
gsnedders wants to merge2 commits intohtml5lib:masterfromgsnedders:constant_phases

Conversation

gsnedders
Copy link
Member

With this we no longer include "process the token using the rules for" phases in the debug log.

This also needs perf review given it touchesmainLoop.

(If you want to view the diff, append?w=1 to the URL to ignore whitespace, otherwise the reindenting of the phases just dominates.)

@codecov-io
Copy link

codecov-io commentedJul 13, 2016
edited
Loading

Current coverage is90.33%

Merging#272 intomaster will decrease coverage by0.10%

@@             master       #272   diff @@==========================================  Files            51         51            Lines          6926       6904    -22     Methods           0          0            Messages          0          0            Branches       1332       1329     -3   ==========================================- Hits           6264       6237    -27- Misses          501        506     +5  Partials        161        161

Powered byCodecov. Last updated by945911b...a120557

@willkg
Copy link
Contributor

@gsnedders Is this important? There's no explanatory issue, so I'm not sure what the value is here and whether we should spend time on it for 1.0 or not.

@gsnedders
Copy link
MemberAuthor

@willkg Reduction in complexity and potentially performance gains by reducing indirection.

@willkg
Copy link
Contributor

Ok. I'm going to push this off until after 1.0, then.

@codecov-commenter
Copy link

codecov-commenter commentedJun 24, 2020
edited
Loading

Codecov Report

Merging#272 intomaster willdecrease coverage by0.03%.
The diff coverage isn/a.

Impacted file tree graph

@@            Coverage Diff             @@##           master     #272      +/-   ##==========================================- Coverage   91.07%   91.03%   -0.04%==========================================  Files          50       50                Lines        7044     7016      -28       Branches     1341     1337       -4     ==========================================- Hits         6415     6387      -28  Misses        475      475                Partials      154      154
Impacted FilesCoverage Δ
html5lib/_utils.py81.25% <ø> (-1.71%)⬇️
html5lib/html5parser.py98.41% <ø> (-0.03%)⬇️
html5lib/tests/test_parser2.py100.00% <ø> (ø)

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last updatef4646e6...db7310d. Read thecomment docs.

This added a fair bit of complexity, and notable made the Phase classesdynamically generated.However, by doing this, we no longer include "process thetoken using the rules for" phases in the debug log.
Copy link
Contributor

@jayaddisonjayaddison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

NB: I've no write or commit access here, but to me these changes look good.

From local checkout & review:

  • Tests pass
  • Performance impact (forparser benchmarks, since that's what this code affects): neutral (cpython 3.9.1)

Although there doesn't seem to be a performance improvement from this, in my opinion it does work towards making the code simpler and opens up future refactoring and cleanup work thatis likely to improve performance in more significant ways.

@@ -201,6 +188,9 @@ def mainLoop(self):
DoctypeToken = tokenTypes["Doctype"]
ParseErrorToken = tokenTypes["ParseError"]

type_names = {value: key for key, value in tokenTypes.items()}
debug = self.debug
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@gsnedders Is there a reason to bringtokenTypes andself.debug into local method variables here?

AtL225 we could compare usingif self.debug and similarly atL226 we could useinfo = {"type": tokenTypes[type]}.

(am guessing it's possibly an artifact of some IDE-based refactoring? Hopefully a straightforward cleanup either way)

else:
return type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nice :) I get some minor worries about difficult-to-debug future issues when built-in Python keywords liketype get used as variables / returned as values. Removing this is a nice improvement 👍

@@ -68,7 +68,6 @@ def test_debug_log():
('dataState', 'InBodyPhase', 'InBodyPhase', 'processStartTag', {'name': 'p', 'type': 'StartTag'}),
('dataState', 'InBodyPhase', 'InBodyPhase', 'processCharacters', {'type': 'Characters'}),
('dataState', 'InBodyPhase', 'InBodyPhase', 'processStartTag', {'name': 'script', 'type': 'StartTag'}),
('dataState', 'InBodyPhase', 'InHeadPhase', 'processStartTag', {'name': 'script', 'type': 'StartTag'}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Good catch! How did you discover this duplicate entry, out of interest?

# pylint:enable=unused-argument


_phases = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The core of the improvement - looks good generally. What do you think about going one step further and moving this to theinitialization of theHTMLParser's self.phases at L121?

@ambvambv mentioned this pull requestMar 3, 2023
@ambv
Copy link
Member

ambv commentedFeb 21, 2024
edited
Loading

This was merged as#567.

@ambvambv closed thisFeb 21, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jayaddisonjayaddisonjayaddison left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@gsnedders@codecov-io@willkg@codecov-commenter@ambv@jayaddison

[8]ページ先頭

©2009-2025 Movatter.jp