Git Product home page Git Product logo

Comments (9)

dw avatar dw commented on September 27, 2024

Hrm annoying, I'd call it a docs bug, since behaviour in CPython (and PyPy) going back forever is that it just takes an iterable. Does MyPy have some kind of override facility? Converting the sets to lists on every loop would be wasteful, just to match basically a doc bug (the structure passed to select is inherently useless and must internally be iterated to transform it into an fdset anyway).

from mitogen.

dw avatar dw commented on September 27, 2024

We could potentially try just replacing the sets with lists, in the usual case they're only going to contain <5 entries anyway, and the code might even end up faster. The question would be after I get async connect finished, whether scanning the lists for add/removal slows down with a master that has hundreds of connections

from mitogen.

dw avatar dw commented on September 27, 2024

I don't think so.. once a connection is established to a context, it is never removed from the readers set (so there is never any scan of the list until a disconnection occurs).

The writers set only contains contexts that currently have data buffered, and in the typical case it'll simply be empty. I'm not sure about the worst case, though

from mitogen.

dw avatar dw commented on September 27, 2024

mind.. blown.. select() is converting the set into a list internally (via PySequence_Fast()). So there's a real chance swapping the set for a list will improve things

from mitogen.

moreati avatar moreati commented on September 27, 2024

THank you for looking. FTR changing the arguments to sorted(self...) didn't make any difference to unit test failures.

Does MyPy have some kind of override facility?

Yes, I can add a # type: ignore on a per-line basis

from mitogen.

moreati avatar moreati commented on September 27, 2024

FTR I've push the MyPy trial to https://github.com/moreati/mitogen/tree/mypy-try. I'm not proposing to do anything more with it. I think I've learned what I can.

from mitogen.

dw avatar dw commented on September 27, 2024

What's your verdict on MyPy? I'm not completely averse to the idea of it, especially since the annotations are just comments, and don't forget you really did find a bug :).. maybe we could merge it

from mitogen.

moreati avatar moreati commented on September 27, 2024

What's your verdict on MyPy?

On a per bug found basis it was an expensive exercise. As a learning exercise for me it was useful. As a way of documenting the APIs in-situ I found it very handy. I don't know of a way to feed MyPy annotations into doctools, so there would be some duplicated effort and or chance of discrepancies there.

I'm not completely averse to the idea of it, especially since the annotations are just comments, and don't forget you really did find a bug :).. maybe we could merge it

Not all the changes are comments, e.g. I sprinked a few asserts, and changed a base class or two

moreati@5df74fc#diff-60eabbf230c5d9137e81bf0f41ed37bbR104
moreati@5df74fc#diff-3540c3617f4566023f000914cebe2d71L317

Edit: I also had to delete the vendored pkgutil to stop an import loop

from mitogen.

dw avatar dw commented on September 27, 2024

Going to close this and open a separate ticket to keep track of your MyPy stuff :)

from mitogen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.