Comments (15)
Maybe we could implement a method self.fastcall()
?
from circuits.
👍 Worth looking in to :)
I suspect it might have something to do with the fact that coroutines are handled in the "next tick" so to speak; whereas fired events are "queued up" for immediately handling.
But maybe we can improve this?
from circuits.
With a much simpler implementation of this "slow test":
from circuits import Component, Event
class counter(Event):
"""counter Event"""
complete = True
class Slow(Component):
def started(self, *args):
# self.fire(counter(10))
yield self.call(counter(10))
def counter(self, n):
for i in xrange(n):
print i
yield i
def counter_complete(self, *args):
raise SystemExit(0)
Slow().run()
I only see a ~10% performance drop in using self.call()
which IHMO is acceptable seeing what it's doing and all :) Thoughts?
from circuits.
That code does not what my code does. You are call()-ing 1 time not 10/30 times (which is a valid use case). Where then 10% is very much. At least it must be documented, also using call() is useless then if it is in the endeffect slower than just fire()ing.
from circuits.
Hmm I'll have to study your contrived example a bit more :) I'm not quite following it yet :)
from circuits.
Real life code is always better: spaceone/circuits.http@ef5d7f6
from circuits.
Yeah okay I see :) I'll have to play with this some more and see what's going on. To be honest I'm not sure why you're using coroutines (or were trying to) there anyway?
from circuits.
Well, I thought call
is not just equivalent to yield self.wait(self.fire(event).event)
. I thought it would just call the event handlers synchroniously. Now I looked at the code and I am smarter ;)
from circuits.
Ahh so in your particular case you were calling the wrong API method? yield self.wait()
is indeed NOT equivalent to self.call()
:) Both in effect create coroutines!
from circuits.
What are the exact differences between call()
and wait()
? In my particular case I want to call the handlers as soon as possible. I probably misunderstood how call()
is meant to be used?
from circuits.
Yeah so call/wait
are essentially the same. .call()
does a .fire()
and .wait()
, whilst .wait()
only wiats for an event's completion. Both are used to write synchronous code that is otherwise asynchronous underneath, both turn the event handler into a coroutine (_because you _have* to yield
*).
from circuits.
Any further thoughts/comments on this? Do we need to change/fix/update anything here? Improve the documentation around this perhaps?
from circuits.
@spaceone Do you have any thoughts on improving this at all -- Or should we just document it better? call/wait
provide coroutines (cooperative threading); I would never expect them to be as performant as "fire and forget". I have however observed the same behaviour as what you've described in that using coroutiens does cost a bit of performance for the sake of "synchronization".
from circuits.
Maybe we could implement a method self.fastcall() ?
I'm not sure; but it would be backwards compatible at least. New API.
from circuits.
Maybe fixing #136 via #213 already solves this problem - at least it gets improoved
from circuits.
Related Issues (20)
- Speed up more tests
- re-raise KeyboardInterrupt
- Drop Python 2 support HOT 9
- remove landscape.io tooling and references HOT 1
- SSL based tests fail on Ubuntu 20.04 HOT 3
- chunked multi-part web posts HOT 10
- 📣 Migrating off of Github 📣 HOT 5
- Migrate circuits.web HTTP parser to httoop HOT 7
- circuits.web.tools.validate_etags(autotags=True) is broken
- Migrate from Travis-CI to github actions HOT 2
- Fix Python 3.10 support HOT 2
- reduce possible XSS attack vector
- Integrate tornado
- allow coroutines with Python 3 syntax as async def functions HOT 4
- circuits.web error handling broken HOT 1
- circuits.web.tools.validate_etags(autotags=True) is broken
- Missing A record for domain circuitsframework.com HOT 9
- failing IRC byte representation
- Couple of questions the documentation seems to be lacking HOT 4
- TravisCI blocks Pull Requests HOT 4
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 circuits.