Comments (1)
The simplest approach would be to factor out the pickle
into a constant. That would allow monkeypatching to work on the hissp
package alone without rewriting the whole method. You still have to patch two places though.
The most correct might be to factor it out into a ContextVar
, which might be the closest thing the Python standard library has to dynamic vars. It's arguably not a monkeypatch at that point. But do we really need that? Would we ever want to use dill
and pickle
in the same session? Maybe, Hissp is not necessarily run where it is compiled. I don't think this buys us much over a constant though. If you need that degree of control, unittest.mock.patch
can swap the context for you as long as you're not threading or doing async shenanigans.
The above is arguably still a monkeypatch because it still needs the pickle
global to be replaced. Ideally, that would read from the same ContextVar
instead, but that would be a bit awkward in any place the compiler is using pickle
, which brings us to the third option: infer the import name pickle
from the .__name__
attr of the pickle
module. This arguably fixes a DRY violation, where the same bit of information is stored in another place, although one too minor to normally bother with considering its greater overhead. However, this would make the first attach
line all you need to monkeypatch to enable dill
. Let's go with that for now.
from hissp.
Related Issues (20)
- `deftype` should be able to take `kwds`
- one time donations problem, please try receive some crypto as donation, maybe nano cryptocurrency
- Rethink `if-else` HOT 12
- Consider inject literals in Lissp (raw symbols) HOT 3
- Gensysms aren't good enough HOT 4
- Build broke on Python 3.11
- Synexpand may be too sensitive HOT 1
- & doesn't factor well in synexpand HOT 7
- Consider making gensym counter a reader instance variable
- Add source links to macros.lissp HOT 1
- defonce defs twice?
- Rename `&&` and `||` to `ands` and `ors` HOT 1
- #241 broke synexpand
- Consider munging `-` as `QzH_` instead of `Qz_`
- Consider a shorter name for `_macro_` HOT 2
- Write a symbol macro let walkthrough
- Stop supporting Python 3.8
- Compiled lambda text layout could be improved HOT 5
- Use terminology more consistently
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hissp.