what is Cpython is this single module or complete Python - cpython

I like to know what is CPython.
What I understood is
Its flavor of python, (correct me if its wrong) so basically systems programming made easy in Python language but again I could not find system calls code in CPython implementation for mmap or etc. does CPython has sockets, listen, accept, send, and recvfrom system calls too for Cpython user developer.
This is the link of Cpython https://github.com/python/cpython so if I install it then will my version already python version Python 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0] on linux will it continue working or do I need to make changes to that.
Can I install any other module and run it in Cpython application?
Thanks for any info

CPython is the “official,” or reference implementation of Python. If you are installing python from python.org you are running Cpython implementation. You can confirm this via platform module.
>>> import platform
>>> platform.python_implementation()
'Cpython'
CPython contains complete implementation of the language(Including standard library/compiler/Byte Code Interpreter etc). If you want to understand how the source code is laid out you can refer Your Guide to the CPython Source Code.
Additional reference:
Python vs Cpython

Related

Compile Java source to LLVM IR [duplicate]

From what I've read, there is a llvm program that converts java bytecode to llvm's intermediate form called class2llvm. My question is, how do I access this. What front end do I have to install in order to access this.
VMkit is their implementation of a JVM, but I am looking for how to compile the java source code with llvm, not how to run it.
The Java frontend translates Java bytecode (.class files) into LLVM
bytecode. Take a look at this link:
https://llvm.org/svn/llvm-project/java/trunk/docs/java-frontend.txt
You may take a look at dragonegg, which enables llvm to use gcc's frontends. As gcc already has a frontend for java, called gcj, perhaps llvm can use it to compile java code. But I'm not sure how well llvm interfaces with the gcc frontend, so this may not work.
I have executed a java class using vmkit ( http://vmkit.llvm.org/ ) based on LLVM. It uses LLVM for compiling and optimizing high-level languages to machine code. J3 is an implementation of a JVM with VMKit.
[NOTE: From November 2015 it is no longer open source, so this hack is mostly useless.]
RoboVM might become the solution you're looking for. It's open source and compiles JVM bytecode (.class files) to machine code.
I assume they do it using something like class2llvm.
Unfortunately, it's still in alpha. I just tested it on HelloWorld.java. It gave 5x speed up of load time running on a single core. (Most of the run time is load time.)
echo Hello World! : <1 ms : 31K (/usr/bin/echo binary)
java HelloWorld : ~70 ms : 0.4K (HelloWorld.class JVM bytecode)
./HelloWorld : ~13 ms : 9.4MB (9.3MB binary + 57K robovm-rt.jar)
Note that java calls a 32MB $JAVA_HOME/lib/rt.jar file (and maybe more). Searching in such a large file must be part of the reason java is so slow to load. If RoboVM gets smarter, perhaps it can throw out most of the 9.3MB binary for an even faster load?
The website mentions iOS, but I think that's because they're selling their add-on UI libraries. RoboVM compiled fine for me on a flavor of Ubuntu. Just make sure to do
$ sudo apt-get install g++-multilib
first (and maybe install libpthread-stubs0-dev and libpthread-workqueue0...don't know if they mattered).

Problems around Gtk and PyGtk

In the code file i have to link just one library (from gi.repository import Gtk).
But when i run it it replies me:
Gtk-WARNING **: Unknown property: GtkTextView.input-purpose
ERROR --file: collega_GUI --riga: 160, 'Grid' object has no attribute
'get_child_at'
So i tried to find missing libraries:
$ dpkg -l libgtk[0-9]* | grep ^i
ii libgtk2.0-0 2.24.10-0ubuntu6 GTK+ graphical user interface library
ii libgtk2.0-bin 2.24.10-0ubuntu6 programs for the GTK+ graphical user interface library
ii libgtk2.0-common 2.24.10-0ubuntu6 common files for the GTK+ graphical user interface library
ii libgtk2.0-dev 2.24.10-0ubuntu6 development files for the GTK+ library
and Grid object needs gtk3+, so let's install it:
$ sudo apt-get install libgtk-3-0 libgtk-3-common libgtk-3-dev libgtk-3-doc
0 updated, 0 installed, 0 removed and 0 not upgraded
So it's all fine with libraries and:
gtk-grid-get-child-at exists
GtkTextView--input-purpose exists
that "input-purpose" problem is strange, because on the previous OS (ubuntu 13.10, now i'm on 12.04) i didn't get that problem.
The UI is built by Glade, but i never get that error previously: on the same project files, but on a different OS version.
I still think i need to install some libraries.
EDIT :: ged_child_at function call
griglia = self.__builder.get_object('grid3')
for i in range(0, 3):
area = griglia.get_child_at(i, 0)
self.__builder.get_object(Gtk.Buildable.get_name(area)).connect("draw", self.draw)
The tag Since 3.6 for that property which means in Gtk+ 3.4 (which is the default of ubuntu 12.04 if I recall correctly).
So you either work around it or you go the thorny way of upgrading to Gtk+ 3.6 - which I - with all respect - do strongly disrecommend - especially since Unity needs various patches being incorporated into Gtk+ to work at all.
I just checked in gtk+-3.10.x the python bindings are fine and include get_child_at(..).
This question contains an answer that in fact this is a bug in the python bindings of gtk+ 3.4.
Solutions: Backport the git commit that fixes this (should be very tiny git commit) recompile/create deb package (significant knowledge required).
An alternate route would be to locally fix the binding specification and recreate the python introspection bindings locally - not sure if that is possible though - never did that.

Qt Creator tag file

I use vim for C++ code editing. But its code completion isn't so good (although I have tried many plugins, such as OmniCppComplete). The Qt Creator code completion is awesome, and it also has vim style editing which functionality is full enough for me. Only thing that isn't so good for me is that I cannot use ctags functionality inside Qt Creator (although Qt Creator has functionality to go to class definition, but it takes a lot more time to parse the source code).
Is it possible to create the source code tag file and use it with in Qt Creator in fake vim mode?
Code completion for C++ in Vim is actually superior. I'll outline the steps you have to take in order to make it work. However, I won't go into much detail here (such as building huge open-source code base, cloning a repository, installing plugins for Vim, etc.) because otherwise it would be worth writing a large tutorial for novices. So, assuming that you are well-aware and well-prepared software developer, there you go a fluent guide:
Get and install clang_complete (plugin for Vim);
Get and install neocomplcache (plugin for Vim);
If you are on Unix, then you are lucky because you probably have LLVM and Clang either installed on your system already or you have to use package manager and install them with a single command. If so, then you can immediately jump to the last step (#7).
If you are on Windows, then you are less lucky, but that's actually better from the practical point of view - you'll have a great experience of building huge stuff on your own and getting things to work no matter what. :)
So, if you're on Windows (and using Qt Creator as I can see), then you might have MinGW already installed on your system. If that's not the case, then I strongly suggest that you to install a bleeding-edge MinGW-w64. Fortunately, you don't have to compile it yourself as rubenvb has kindly built MinGW-w64 toolchain in both variants: targeting 64-bit Windows (aka x64) and targeting 32-bit Windows (aka x86). Just download one depending on your OS. NOTE: These links are pointing to the latest (at the time of writing this answer) stable builds of MinGW-w64, i.e. based on GCC 4.7.2. IMPORTANT: Make sure that MinGW-w64 is in the %PATH% environment variable.
Another piece of software needed is CMake (a popular build system). Again, if you are on Unix it might be installed already. If you are on Windows, then just download and install it. IMPORTANT: Make sure that CMake is in the %PATH% environment variable.
The last thing we'll need is Python. Once again, if you are on Unix, then it is already installed on your system. Otherwise, you know what to do already. :) Officially, there are 2 versions of Python: 2.7.3 and 3.x.x - you should definitely download and install both. Python is an essential piece of software on any developer's machine. IMPORTANT: Make sure that Python 2.7.3 (not 3.x.x!) is in the %PATH% environment variable.
Now that we have MinGW-w64, CMake, Python installed, we are ready to build LLVM and Clang. To ease the pain go to my Out-of-Source Builders project and scroll down to Guide: Build 64-bit LLVM and Clang for Windows (64-bit) Using MinGW-w64. If you are on 32-bit Windows, don't pay attention to 64-bit (it does not matter) in the title, just follow the instructions there. Wait for about an hour until LLVM and Clang are built.
We are almost done, all that is left is to configure Vim properly. Here I'll simply provide my configuration which would most likely satisfy your needs.
Configure neocomplcache:
let g:neocomplcache_enable_at_startup = 1
let g:neocomplcache_enable_smart_case = 1
let g:neocomplcache_enable_camel_case_completion = 1
let g:neocomplcache_enable_underbar_completion = 1
let g:neocomplcache_min_syntax_length = 2
if !exists('g:neocomplcache_force_omni_patterns')
let g:neocomplcache_force_omni_patterns = {}
endif
let g:neocomplcache_force_overwrite_completefunc = 1
let g:neocomplcache_force_omni_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
let g:neocomplcache_force_omni_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)'
\ . '\|\h\w*::'
let g:neocomplcache_force_omni_patterns.objc = '[^.[:digit:] *\t]\%(\.\|->\)'
\ . '\|\h\w*::'
let g:neocomplcache_force_omni_patterns.objcpp = '[^.[:digit:] *\t]\%(\.\|->\)'
\ . '\|\h\w*::'
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
Configure clang_complete:
let g:clang_use_library = 1
let g:clang_auto_select = 0
let g:clang_complete_auto = 0
let g:clang_complete_copen = 1
let g:clang_complete_macros = 1
let g:clang_complete_patters = 1
let g:clang_library_path = 'D:/Toolchains/x64/LLVM/3.3/bin'
let g:clang_auto_user_options = 'path, .clang_complete'
For more information on both of these plugins use Vim's help documentation: :h clang_complete and :h neocomplcache. There are lots of options to tweak, especially in neocomplcache. From my point of view both plugins are must have for any C++ developer who uses Vim.
NOTE: If you don't know how to complete some of the steps listed here, you would have to either ask additional questions here on StackOverflow or look elsewhere for the reason described in the beginning of this answer.
I hope this helps and you would favor Vim more for your development efforts from now. :)

using a foreign library in sbcl - uffi or cffi?

I am an struggling with using a C++ library I have just sucessfully
compiled on ubuntu in sbcl.
I have tried to use the .h file parser 'ah2cl' but from the
documentation it is not clear if I require UFFI or CFFI (is there a
difference?). My attempts to use the dummy test library and the
dummy header file provided with 'ah2cl' have failed. I get a message
about a missing CALLBACK package from sbcl. But does sbcl not support
callback natively ?
Is there another .h file parser that I should use for this
kind of task ?
You might want to try CFFI's groveller, which parses header files to produce the corresponding CFFI bindings. BTW, UFFI is basically deprecated in favour of CFFI for a while now.

none of fink macports and homebrew useful on lion?

I have an library (flam3) that depends on a few utility libraries from unix (xml2, jpeg, png, z) and I am trying to make an application on Lion that uses it. I am building with the latest Xcode and when I try to link with the libraries from fink, macports, and homebrew I get the same error:
ld: warning: ignoring file /opt/local/lib/libxml2.a, file was built
for archive which is not the architecture being linked (i386)
and the libraries look different from ones that work:
bash-3.2$ file /sw/lib/libxml2.a
/sw/lib/libxml2.a: current ar archive random library
by comparision
bash-3.2$ file ~/Documents/FLAM3/libflam3.a
/Users/spot/Documents/FLAM3/libflam3.a: Mach-O universal binary with 2
architectures
/Users/spot/Documents/FLAM3/libflam3.a (for architecture x86_64):
current ar archive random library
/Users/spot/Documents/FLAM3/libflam3.a (for architecture i386):
current ar archive random library
that's the library that I compiled with Xcode.
Is there any way to get Xcode to accept this library? Is there any way to get fink/macports/homebrew to generate a library that works with Xcode? Seems like I am "doing it wrong" as these projects would all be useless if everyone had this problem.... but I don't feel like I've done anything unusual. Help?
The problem is that your libxml2.a is not built as "Universal binary". I.e. it doesn't contain all necessary architectures (In your case I believe it is i386). You need to ask fink, macports, or homebrew to build/download/install library with all necessary platforms. I know that macports has such flag (I don't remember how it's called).
The "file" command list all available architectures for .a file only when the file is trully universal (contains two or more of ppc, i386, x86_64), otherwise it only shows the vanilla "ar archive..." message. That confirms your libxml2.a has only one architecture.
The problem is not in Xcode or Lion. Possibly the default link architecture on Lion changed.

Resources