Giter VIP home page Giter VIP logo

Comments (5)

mottosso avatar mottosso commented on May 30, 2024

PyQt has this convenience feature that when you import PyQt5.Qt it will import all classes under the same namespace. So even if you aren't using QtQml, it would still get imported, which I am just assuming adds to the amount of time it takes to import.

I'm sure there is reference of it in the documentation, but couldn't find it just now. This was the closest thing I found.

To solve this, I would rather find a way of only importing what the user actually imports.

from Qt import QtWidgets
# Should not import QtCore, QtQuick.. etc.

Alternatively if we test and make sure it actually does take longer, maybe it doesn't, in which case there's nothing to worry about.

from qt.py.

pipoun avatar pipoun commented on May 30, 2024

With current Qt.py implementation, in function _pyqt4() if you replace

import PyQt4.Qt

with

import PyQt4.QtCore
import PyQt4.QtGui

to avoid importing PyQt4.Qt (and the performance hit), the following code doesn't work any more.

>>> import Qt
>>> import Qt.QtSvg
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: dynamic module not initialized properly

from qt.py.

mottosso avatar mottosso commented on May 30, 2024

Yes, importing it all at once has been the only way I haven't run into problems. Me thinks there is some magic happening on import of the PyQt modules.

from qt.py.

fredrikaverpil avatar fredrikaverpil commented on May 30, 2024

This thread is interesting and somewhat related to this issue: https://www.riverbankcomputing.com/pipermail/pyqt/2016-September/038019.html

"from foo import bar" is equivalent to:

   import foo
   bar = foo.bar
   del foo

from qt.py.

mottosso avatar mottosso commented on May 30, 2024

This isn't solvable anymore, since 1.0, as we are explicitly importing every single member in order to map it correctly. Nor may it ever have needed a solution.

from qt.py.

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.