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

Intern string#1254

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

Merged
lostmsu merged 2 commits intopythonnet:masterfromamos402:intern-string
Nov 6, 2020
Merged

Intern string#1254

lostmsu merged 2 commits intopythonnet:masterfromamos402:intern-string
Nov 6, 2020

Conversation

amos402
Copy link
Member

What does this implement/fix? Explain your changes.

Use the intern strings map to const strings instead of creating temporary strings everytimes.

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • If an enhancement PR, please create docs and at best an example
  • Add yourself toAUTHORS
  • Updated theCHANGELOG

Comment on lines +1 to +4
<#@ template debug="true" hostSpecific="true" #>
<#@ output extension=".cs" #>
<#
string[] internNames = new string[]
Copy link
Member

Choose a reason for hiding this comment

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

Why use a template generator, when you can simply getinternNames from reflection? It looks like unnecessary complication.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Two reasons make this scenario happened.

  1. You need to make sure the string is a c# intern string too to make code like this work without extra checking
conststrings="1";switch(    case"1":// both "1" point to the same stringbreak;
  1. If you need (1), you have to make theinternNames set on compile.
    Of course, if you don't (1), internNames can just set by using reflection from readingPyIdentities.

christabella reacted with thumbs up emoji
@codecov-io
Copy link

codecov-io commentedOct 22, 2020
edited
Loading

Codecov Report

Merging#1254 intomaster willnot change coverage.
The diff coverage isn/a.

Impacted file tree graph

@@           Coverage Diff           @@##           master    #1254   +/-   ##=======================================  Coverage   86.25%   86.25%           =======================================  Files           1        1             Lines         291      291           =======================================  Hits          251      251             Misses         40       40
FlagCoverage Δ
setup_linux64.94% <ø> (ø)
setup_windows72.50% <ø> (ø)

Flags with carried forward coverage won't be shown.Click here to find out more.


Continue to review full report at Codecov.

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

@lostmsu
Copy link
Member

@amos402 did you have a chance to compare benchmarks on your branch withInteropString.GetManagedString replaced byRuntime.GetManagedString?

@amos402
Copy link
MemberAuthor

amos402 commentedNov 6, 2020
edited
Loading

https://gist.github.com/amos402/8decd54dee57fe654e098bc0b15c061a

CPU: Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
Python Version: 3.8.6

functionoriginintern-stringwithout Intern.GetManagedString
get_doc0.31777 (100.00%%)0.18106 (56.98%%)0.32203 (101.34%%)
get_attr_doc0.3397 (100.00%%)0.20156 (59.33%%)0.34397 (101.26%%)
get_attr_doc_concat0.34546 (100.00%%)0.42619 (123.37%%)0.34862 (100.91%%)
lostmsu and christabella reacted with thumbs up emoji

@lostmsulostmsu merged commitd0c588b intopythonnet:masterNov 6, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@lostmsulostmsulostmsu approved these changes

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

Successfully merging this pull request may close these issues.

3 participants
@amos402@codecov-io@lostmsu

[8]ページ先頭

©2009-2025 Movatter.jp