why function throws an error?

15 views
Skip to first unread message

נתי שטרן

unread,
Jun 28, 2022, 3:58:36 AMJun 28
to
def add_route(self, route):
# """ Add a route object, but do not change the :data:`Route.app`
# attribute."""
self.routes.append(route)
self.router.add(route.rule, route.method, route, name=route.name
)
# if DEBUG: route.prepare()
--
<https://netanel.ml>

Mirko

unread,
Jun 28, 2022, 5:12:37 AMJun 28
to
Am 28.06.22 um 09:57 schrieb נתי שטרן:
Are you still trying to combine different modules into one large
module? That is not going to help you. First, you need to rewrite
all those modules to seamlessly work together. This will likely be a
huge task. Let's say you have a module that defines some function
route():

def route():
print("route")

Another module defines a variable called "route":

route = True

A third module needs to call the function from the first module, but
this fails now because the second module has overwritten (shadowed)
the former function with a variable:

route = True
route()

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'bool' object is not callable


You would need to find all those cases where one module overwrites
variables or functions from other modules. And sometimes those cases
will be difficult to spot. Python is not designed for what you are
trying to do. Even if you get this done, it will not help you. You
can't just throw everything into a single file and then magically
optimize it. When you have this huge final module, what do you think
you can do with it to be faster?

If you have performance problems with some module, you have several
options to optimize it:

- Find a better algorithm.
- Rewrite performance-critical parts in Cython or even C and import
the compiled module.
- Use a JIT compiler such as PyPy

Dennis Lee Bieber

unread,
Jun 28, 2022, 9:33:40 AMJun 28
to
On Tue, 28 Jun 2022 10:57:59 +0300, ??? ???? <nsh...@gmail.com> declaimed
the following:
From your subject "why function throws an error?".

How would we know? You never show us the error traceback, you never
provide a minimal code listing that someone could attempt to run to perform
debugging.



--
Wulfraed Dennis Lee Bieber AF6VN
wlf...@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

Lars Liedtke

unread,
Jun 28, 2022, 11:29:59 AMJun 28
to
Hey,

Which error does it throw?
Could you please send the stacktrace as well?

Cheers

Lars


--
Lars Liedtke
Software Entwickler


Phone:
Fax: +49 721 98993-
E-mail: l...@solute.de


solute GmbH
Zeppelinstraße 15
76185 Karlsruhe
Germany


Marken der solute GmbH | brands of solute GmbH
billiger.de | Shopping.de


Geschäftsführer | Managing Director: Dr. Thilo Gans, Bernd Vermaaten
Webseite | www.solute.de
Sitz | Registered Office: Karlsruhe
Registergericht | Register Court: Amtsgericht Mannheim
Registernummer | Register No.: HRB 110579
USt-ID | VAT ID: DE234663798


Informationen zum Datenschutz | Information about privacy policy
http://solute.de/ger/datenschutz/grundsaetze-der-datenverarbeitung.php

Am 28.06.22 um 09:57 schrieb נתי שטרן:
> def add_route(self, route):
> # """ Add a route object, but do not change the :data:`Route.app`
> # attribute."""
> self.routes.append(route)
> self.router.add(route.rule, route.method, route, name=route.name
> )
> # if DEBUG: route.prepare()
> --
> <https://netanel.ml>

Reply all
Reply to author
Forward
0 new messages