Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Joshua Bronson
@jab
Hi @/all, made some significant performance improvements to bidict recently! See http://bidict.rtfd.io/changelog.html#speedups-and-memory-usage-improvements for a summary. I've released them in the development version 0.15.0.dev1. If you get a chance, please kick the tires let me know how it goes.
Joshua Bronson
@jab
Please also see #62 and #63 and :+1: if interested.
Joshua Bronson
@jab
@/all I just released bidict v0.15.0 with significant performance and other improvements. Please see https://bidict.readthedocs.io/en/v0.15.0/changelog.html for the full release notes. Upgrading is recommended to all users. When you get a chance to try it, please let me know how it goes. Thanks!
Joshua Bronson
@jab
Hi @/all, released a few new versions of bidict recently with the latest being 0.17.2. Please see https://bidict.readthedocs.io/changelog.html for release notes.
Joshua Bronson
@jab
@/all I'm looking for feedback on the proposal in #86. If you have any thoughts, please share!
Joshua Bronson
@jab
@/all just released bidict v0.18.0. Please see https://bidict.readthedocs.io/changelog.html for release notes.
Joshua Bronson
@jab
@/all just released bidict v0.18.1 with a small bugfix for deepcopied and unpickled bidicts. Thanks to @uduse for reporting!
Joshua Bronson
@jab
Hi @/all, as promised in September’s v0.18.2 release, I’ve just merged changes to master that drop support for Python 2. This work was done in #99, and will enable future improvements such as #93. Please let me know if you have any questions or feedback! /cc @lordmauve @rsanger @gaborbernat @cjgibson
Joshua Bronson
@jab
Hi @/all, I'm considering making some small (but overdue) API refinements. Please see #107 / https://bidict.rtfd.io/en/dev/changelog.html for the proposed changes and let me know if you'd like to give feedback before I merge them. Hoping to get a new release out soon with these changes as well as the already-merged changes that dropped Python 2. /cc @gaborbernat @lordmauve @rsanger et al.
Richard Sanger
@rsanger
@jab I don't use these parts of the API but I've checked nothing else has unexpectedly broken in my code with this release.
Thanks for all your hard work on this and your documentation effort, I particularly appreciated that a pip install with python2 fails and spits out a nice error message.
Joshua Bronson
@jab
Thanks so much for testing and reporting back, @rsanger, it's a huge help!!
Joshua Bronson
@jab
Good to know you don't use the parts of the API I changed. I expect most users don't use them. And for those that do, I added the backwards-compatible aliases and a warning to use the new spellings when the old ones are detected.
Joshua Bronson
@jab
@/all, I just released bidict v0.19.0, the first release that doesn't support Python 2. It also has some minor optimizations and API refinements. See https://bidict.rtfd.io/en/v0.19.0/changelog.html for details. Please upgrade when you can and let me know if you have any issues.
Bernát Gábor
@gaborbernat
Looks good for me
Joshua Bronson
@jab
Thanks for confirming, @gaborbernat. Glad to have one less thing in the way of some type-hinted version of bidict in the future.
Joshua Bronson
@jab
Hi @/all, any typing / mypy experts in the house? I think that current limitations in mypy may be preventing me from type hinting bidict properly (see https://github.com/jab/bidict/issues/93#issuecomment-602129295). Originally I was going to ask if any mypy experts were going to be at PyCon and could take a look at this with me there. But now that it's canceled, if anyone who would have been available to help there would be willing to take a look some other time, please let me know. Users are increasingly requesting type hints for bidict, so it'd be nice to provide them once mypy lets us do so properly (which maybe we can help with!).
Bernát Gábor
@gaborbernat
I'd not qualify myself as mypy expert, but tried to modify their code at some point so maybe; though they are very responsive in their gitter chat
Joshua Bronson
@jab
Thanks Bernat, I actually posted there too yesterday (https://gitter.im/python/typing?at=5e77874f2fba7b70a0c728e0) – haven't gotten a reply yet but hopefully will.
@gaborbernat, is there anyone in particular you're aware of who's offered to help with more advanced typing questions like this one? (Namely how to type hint BidirectionalMapping.inverse such that the type of any subclass B is inferred correctly as B[VT, KT] – I don't think it's currently possible to compose type variables such that mypy understands this.)
Bernát Gábor
@gaborbernat
you're best chance is either Jukka Lehtosalo, or Ethan Smith or Guido; one of them will know
can you createe a 50 lines demo that replicates the feature gap outside of bidict
usually, that helps a lot
Joshua Bronson
@jab
Thanks, @gaborbernat. It's harder because unlike bidict, for all other Generic types, all their methods' return types don't need to remix/recompose the self type with the generic contained type (e.g. the key and value types). Are you aware of any other type that does this?
Bernát Gábor
@gaborbernat
considering you expressed the type to be generic, and you've correctly qualified the type variables in the interface I see no reason why you could not swap the typevars within the response
I'm making a few assumptions here tbf, that's why ideally a 50 lines of less demo would help to see exactly what's the issue
Joshua Bronson
@jab
Makes sense, I'll try to work one up.
Bernát Gábor
@gaborbernat
if indeed is a feature gap it could be used as test when the feature is implemented; or as base for people to play around to come up with a workaround in the meantime
Joshua Bronson
@jab
:thumbsup:
Another factor that may be complicating things for a minimal example is inheriting from Mapping[KT, VT].
Bernát Gábor
@gaborbernat
that's alright IMHO
Joshua Bronson
@jab
It'd be helpful to have some examples of other types that subclass Mapping[KT, VT] and then do fancier things with the self type.
I just haven't found any.
Bernát Gábor
@gaborbernat
if you make the minimal repro I can try to look into it what's the underlying problem
Joshua Bronson
@jab
Thanks @gaborbernat, much appreciated! I'll hope to get to this by later in the week and get back to you (though anyone else interested please feel free to beat me to it!)
python/mypy#2354 may actually be the issue I'm hitting.
I'll post back in the #typing chat.
Ethan Smith
@ethanhs
Hey @jab, happy to answer questions you have
I'm looking through the problem you are describing and it seems that what you want are higher kinded types, which mypy does not support. Essentially what you need that mypy doesn't support is a function like def foo(self: B) -> B[VT, KT]: ...?
Joshua Bronson
@jab
Thanks @ethanhs! Yes, and now I’ve rediscovered python/typing#548 (which I see I originally found and subscribed to while looking at this a couple months ago and then lost track of). Is that the issue to fix before we can add proper type hints to bidict? Do you have a sense for the effort required or the appetite for resolving this? Thanks again!
Ethan Smith
@ethanhs
It would be a lot of work and I don't think anyone is planning on working on it
sorry :(
You may be able to fake an equivalent thing with a plug-in for now
Bernát Gábor
@gaborbernat
AFAIU this only affects the invert function; so without you would be able to type everything else, just not invert
and make the plugin for the invert; but then users would need to install that for mypy
Ethan Smith
@ethanhs
^ this is correct
Joshua Bronson
@jab
@ethanhs @gaborbernat, thanks for the suggestion. Re "this only affects the inverse property", that may be true, but inverse accounts for an outsized share of a bidict's value, since it is not only a view of the inverse bidict, but also the main interface for getting and setting keys by value on the forward bidict. So I think the proposal to "type hint everything but inverse" (in a way that is understandable by mypy without any custom plugins) might provide a lot less value than you expect.
That said, a bidict user who never needed to use the inverse property would still get a lot of value out of the rest of its implementation of the MutableMapping interface, since it enforces the uniqueness of values constraint.
Joshua Bronson
@jab
But as a solo, voluntary maintainer of bidict who can only afford to work on bidict on nights and weekends, I unfortunately don't have the resources to devote to developing any custom mypy plugins at this time. And even if I did, I would be concerned that the effort required would not be worth the value provided by such a partial solution – how many users would actually use the plugin, how well would it integrate into everyone's various workflows, IDEs, continuous integration, etc. etc. Let me know if I'm missing something, but at this point the value proposition does not seem compelling enough.
Joshua Bronson
@jab
In the meantime, it does seem worth reporting back in all the relevant, open mypy/typing issues that they're currently holding back proper type hinting for data structure libraries like bidict, so that people know there are other very concrete use cases affected here. @ethanhs, given how active you've been in the mypy project and your greater level of understanding of what's needed, would you be willing to leave a quick comment to this effect on the relevant issue(s)?
Thanks so much again for taking the time to advise on this.