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

Codec groups: EncoderGroup and DecoderGroup#1085

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
filmor merged 2 commits intopythonnet:masterfromlosttech:PR/CodecGroups
Apr 22, 2020

Conversation

lostmsu
Copy link
Member

@lostmsulostmsu commentedMar 10, 2020
edited
Loading

What does this implement/fix? Explain your changes.

These classes would help to manage codec layers. For example, a library could register its own codecs, but also allow anyone to inject their codecs before library's own:

publicstaticEncoderGroupBeforeLibraryEncoders{get;}=new EncoderGroup();LibraryRegisterCodecs(){PyObjectConversions.RegisterEncoder(BeforeLibraryEncoders);PyObjectConversions.RegisterEncoder(LibraryEncoder.Instance);}

Then in a program using that library:

Library.BeforeLibraryEncoders.Add(preencoder);

Does this close any currently open issues?

No

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

@lostmsulostmsu added this to the2.4.1 milestoneMar 10, 2020
@codecov-io
Copy link

codecov-io commentedMar 10, 2020
edited
Loading

Codecov Report

Merging#1085 intomaster willincrease coverage by0.30%.
The diff coverage isn/a.

Impacted file tree graph

@@            Coverage Diff             @@##           master    #1085      +/-   ##==========================================+ Coverage   86.75%   87.05%   +0.30%==========================================  Files           1        1                Lines         302      340      +38     ==========================================+ Hits          262      296      +34- Misses         40       44       +4
FlagCoverage Δ
#setup_linux65.56% <ø> (ø)
#setup_windows73.82% <ø> (+2.30%)⬆️
Impacted FilesCoverage Δ
setup.py87.05% <0.00%> (+0.30%)⬆️

Continue to review full report at Codecov.

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

These classes would help to manage codec layers. For example, a library could register its own codecs, but also allow anyone to inject their codecs before library's own:public static EncoderGroup BeforeLibraryEncoders { get; }    = new EncoderGroup();void LibraryRegisterCodecs(){  PyObjectConversions.RegisterEncoder(BeforeLibraryEncoders);  PyObjectConversions.RegisterEncoder(LibraryEncoder.Instance);}Then in a program using that library:Library.BeforeLibraryEncoders.Encoders.Add(preencoder);
@filmorfilmor self-assigned thisApr 9, 2020
usingSystem.Linq;
usingNUnit.Framework;
usingPython.Runtime;
usingPython.Runtime.Codecs;
Copy link
Member

Choose a reason for hiding this comment

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

While I don't have a particular problem with this, why are you using this style? It's not in use in the established codebase and I have never seen it outside either.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Imagine we use aSystem.Uri a lot. At some point in the future we decide to take a dependency (or introduce our own) on something, that hasPython.Uri class, which we might not need ourselves, but it is public.

With

usingSystem;namespacePython.Runtime{classSomeClass{UriuriField;}}

theuriField will silently change its type fromSystem.Uri toPython.Uri.

If theusing System; is insidenamespace Python.Runtime, that won't happen.

publicPyObjectTryEncode(objectvalue)=>this.GetRawPythonProxy();
}

classFakeDecoder<TTarget>:IPyObjectDecoder
Copy link
Member

Choose a reason for hiding this comment

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

Maybe give this a few lines of documentation to make it easier to follow the tests.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

@filmor renamed classes to make their behavior more clear, and added xmldoc.

@lostmsulostmsu requested a review fromfilmorApril 14, 2020 04:02
@filmorfilmor merged commit555f562 intopythonnet:masterApr 22, 2020
@lostmsulostmsu modified the milestones:2.4.1,2.5.0Apr 23, 2020
AlexCatarino pushed a commit to QuantConnect/pythonnet that referenced this pull requestJun 29, 2020
* Added Codecs: EncoderGroup and DecoderGroupThese classes would help to manage codec layers. For example, a library could register its own codecs, but also allow anyone to inject their codecs before library's own:public static EncoderGroup BeforeLibraryEncoders { get; }    = new EncoderGroup();void LibraryRegisterCodecs(){  PyObjectConversions.RegisterEncoder(BeforeLibraryEncoders);  PyObjectConversions.RegisterEncoder(LibraryEncoder.Instance);}Then in a program using that library:Library.BeforeLibraryEncoders.Encoders.Add(preencoder);
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@filmorfilmorfilmor approved these changes

Assignees

@filmorfilmor

Labels
None yet
Projects
None yet
Milestone
2.5.0
Development

Successfully merging this pull request may close these issues.

3 participants
@lostmsu@codecov-io@filmor

[8]ページ先頭

©2009-2025 Movatter.jp