Saravanan666/pypi-org huggingface dataset:
Package: localwiki-import-kml
Testing out a KML importer using the LocalWiki API.  Rough right now.To install:$ pip install localwiki-import-kmlTo run:Make sure you have either the geodjango requirements (GEOS, GDAL, PROJ.4)
or localwiki installed.  If you’ve got a development install of localwiki,
make sure you’re inside of the localwiki virtualenv.  Then just run:$ localwiki-import-kml
Package: localwiki-import-wikis
These are scripts to import legacy wiki engines (MediaWiki, Sycamore / WikiSpot.org) into LocalWiki.Very rough right now. Please tell us about your experiences on #localwiki on Freenode.Usage-----To import pages from an existing MediaWiki site into LocalWiki, do the following:1. Activate the virtualenv used for LocalWiki (typical path shown)::$ source /usr/share/localwiki/env/bin/activate2. Install the localwiki-importers package::(env)$ pip install localwiki-import-wikis3. Add 'localwiki_importers' to LOCAL_INSTALLED_APPS in /usr/share/localwiki/conf/localsettings.py::LOCAL_INSTALLED_APPS = ('import_wikis',)4. Now you can run the import command like this::$ localwiki-manage import_mediawikiFollow the prompts to complete the import!5. Build the search index::$ localwiki-manage rebuild_index6. The import will grab users and their edit history, but it won't import theiremail address or password.  If you have a way to obtain the old userpasswords, you can run the following::$ localwiki-manage import_mediawiki --users_email_csv=<users_csv>Where `users_csv` is a CSV file of the form username,email,<optional real name>.Users will then be able to log in after they reset their password.Here's how to get a users CSV file using MySQL::SELECT user_name,user_email,user_real_name FROM wiki_user INTO OUTFILE '/tmp/users.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'The file will then be at `/tmp/users.csv`.Apache config-------------There is an example apache config in conf/ that will help with migratingold mediawiki-style URLs.  We strive for near 100% URL compatibilitywith MediaWiki because breaking links just isn't cool.------------Copyright (c) 2012 Philip Neustrom <philipn@gmail.com>Copyright (c) 2012 Mike Ivanov <mivanov@gmail.com>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Package: localytics
Python Client for Localytics Raw Data ExportThis is a Python API Client forLocalytics Raw Data Export. It allows to export all events and sessions captured by Localytics. Data is written in JSON and available on hourly basis as log files.InstallationThe client is currently best installed via Pypi:$pipinstalllocalyticsUsageLet's have a walk through the functionalities through a couple of examples. Start by loading the library.>>>fromlocalyticsimportLocalyticsSetup and AuthenticationIn order for you to access the KPI Service, you need to authenticate withapi_key. Yourapi_secret, once you supply it, will be used throughout the entire session.>>>localytics=Localytics(api_key='XXXXX',api_secret='YYYYY')Download DataThere is a methoddownload_datathat downloads data to local folder. Example shows how to export data for last 2 days:>>>localytics.download_data(app_ids=['AAAAA','BBBBB'],start_date=datetime.today()-timedelta(2),end_date=datetime.today())You can also specify optional parameters. This is more complex example:>>>localytics.download_data(app_ids=['AAAAA','BBBBB'],start_date=datetime.today()-timedelta(2),end_date=datetime.today(),destination_folder='data',compressed=True)On default data are stored inlocalytics_datafolder and compressed ingzformat. Please setcompresses = Trueif you want to store data decompressed.Contributions and bug reports.Contributions and bug reports are only acceptable as GitHub Pull Requests and issues. Thanks!
Package: localzone
A low-calorie library for managing DNS zonesimportlocalzonewithlocalzone.manage("db.example.com")asz:r=z.add_record("greeting","TXT","hello, world!")r.name# the record name, i.e. "greeting"r.rdtype# the record type, i.e. "TXT"r.content# the record content, i.e. "hello," "world!"Powered bydnspython.FeaturesA simple API focused on managing resource records in local zone filesSupport for almost all resource record typesAuto-save and auto-serialBuilt for automationInstalling localzone$pipinstalllocalzoneRaison d’êtreComprehensive, low-level DNS toolkits can be cumbersome for the more common zone management tasks–especially those related to making simple changes to zone records. They can also come with a steep learning curve. Enter localzone: a simple library for managing DNS zones. Whilelocalzonemay be a low-calorie library, it’s stuffed full of everything that a hungry hostmaster needs.LicenseBSDCalzone image by sobinsergey from the Noun ProjectWhere did the calories go? The likelysuspect.
Package: locan
Welcome to LocanLocan is a python-based library with code for analyzing fluorescence super-resolution
microscopy data.Getting StartedTo install the package please read theinstructionsor:pip install locanor:conda install -c conda-forge locanFor details on usage and development please read thedocumentation.Tutorialsare provided as Jupyter notebooks.You can use the package in a docker container as described indocker/README.md.ContributingDevelopment takes place on theLocan GitHub page.Please useGitHub issuesto report bugs and feature requests.
UseGitHub discussionsfor Q&A.Please readdocumentation on developmentfor details on how to help develop this project further.DevelopersSee the list ofcontributorswho participated in this project.LicenseThis project is licensed under the BSD-3 License - see theLICENSEfile for details.CitingIf you want to acknowledge locan please cite the following publication:Sören Doose, LOCAN: a python library for analyzing single-molecule localization microscopy data, Bioinformatics 38(9), 2670–2672, 2022,https://doi.org/10.1093/bioinformatics/btac160Or cite this repository using the DOI provided by zenodo:doi.org/10.5281/zenodo.5722472Note this DOI will resolve to all versions of locan.
To cite a specific version please find the DOI of that version on the zenodo page.
Package: locapip
C++嵌入式Python微服务C++ embedded Python microservices1 简介locapip是一个小型gRPC运行框架，适用于内嵌Python解释器的C++项目。结合locapic，可与虚幻引擎项目优雅集成2 服务端2.1 安装python-mpipinstalllocapip2.2 启动python-mlocapip--port6547--configCONFIG_JSON其中，CONFIG_JSON是配置文件的路径，定义启用的protobuf模块及其参数{"test":{},"fit_fill":{},"explorer":{"working_directory":"d:/"},"your_protobuf_module":{"path":"path/to/your_protobuf_module.py"}}3 客户端3.1 PythonTODO3.2 C++需结合C++接口locapic使用locapic，借助pybind11的嵌入式Python解释器，提供了一套通用的C++接口使用locapipTODO4 自定义模块服务端和客户端的具体实现方法，请参阅test.py源码，以及gRPC Python和Examples服务端和客户端都应能够访问同一版本的protobuf模块，因此配置文件中定义的模块名称和路径应相同
Package: locass
Locass - Simple and easy to use localization library written on PythonLoCalization As So Simple - simple, light-weight, and simple to use library which help you to localizate your apps on different languages.Note: This project is unstable because of the first releases not tested. We are asking you to report any bugs you found.How to useStep 1: Create a folder with your localization files, for example locals.We recommend you to create it in the root of your project or in the same directory with your executable because we recommend you to use RELATIVE paths like./locals/Step 2: Create localization files using your own markers or use default, markdown is:KEYMARKER(keyvalue)VALUEMARKER(value), consider that spaces between markers and values are forbidden. For example:[k]HW![v]Привет Мир!Step 3: Install and import this module in your project. Details about installing is on Installing page. Next, create a LocalManager object. Use expression like this:man=locass.LocalManager()Step 4: configure localization manager, usingman.configure()function. First argument is the path, where your localization files are, for example "./locals/"NOTE: Please, don't lose "/" symbols!Second argument is the dictionary, which contains the localization name as a key and name of file as a value, for example {"RU": "ru.lang", "EN": "en.lang"}Third is the Keymarker of your markdown you used in localization files, for example "[k]"Last is the Valuemarker of your markdown, for example "[v]"So if you used next markdown of localization flies:file ru.lang in ./locals/ with inside[k]HW![v]Привет Мир!and file en.lang in the same directory with inside[k]HW![v]Hello World!your call will be like:man.configure("./locals/",{"RU":"ru.lang","EN":"en.lang"},"[k]","[v]")Step 5: Load language to use, usingloadLang(key)where key is localization name from previous step, for example "RU":man.loadLang("RU")Step 6: Use it in your code, and when you need string from selected localization, only callg(key), where key from your localization file. For example after steps above we can call next:man.g("HW!")#Returns Привет Мир!Note: To change the loaded language, only call loadLang again with new argument, for exampleman2.configure("./locals/",{"RU":"ru.lang","EN":"en.lang"},"[k]","[v]")man2.loadLang("RU")man2.g("HW!")#Returns Привет Мир!man2.loadLang("EN")man2.g("HW!")#Returns Hello World!InstallingGet it form PyPi:https://pypi.org/project/locass/or in terminal runpip install locassorpip3 install locassTestsTry and see how the library works only runningtests/test.py. Run it only after installing the library or it won't work.Bugs and errorsNow library is under development so we asking you to tell us about every bug or error you found. You should consider that library is unstable and can cause some errors.
Package: locate
LocateThis library provides three callables:this_dir()returns the directory of the current Python file, or when using from an interactive session, it returns
the current working directory.append_sys_path(relative_path)allows importing from a location relative to the running Python file by
resolvingrelative_pathrelative tothis_dir()and appending it tosys.path(e.g.relative_path="../foo/bar").
This also works as a context manager to allow temporary effect (e.g.with append_sys_path("foo"): ...).prepend_sys_path(relative_path)is the same asappend_sys_path, but prependingsys.pathin order to be the first
import location for Python to search rather than the last.SafetyThe*_sys_pathdestructors (when exiting the with block) are safe from any side effect your package imports may have
onsys.path. It's not a naive implementation such as removing the first/last element or removing the element by value;
it employs a string subclass with an additionalidproperty to keep tags ofsys.pathinsertions. It is, therefore,
completely safe and allows for any further nesting ofwith *_sys_pathwithin the import tree.ExamplesInputimportlocatefrompathlibimportPaththis_dir=locate.this_dir()print(f"This file is located in:{this_dir}")print()# Create files to demonstrate importing from a directoryfoo=Path(locate.this_dir(),"foo")foo.mkdir(exist_ok=True)Path(foo,"bar1.py").write_text("print('Importing bar1')")Path(foo,"bar2.py").write_text("print('Importing bar2')")Path(foo,"bar3.py").write_text("print('Importing bar3')")Path(foo,"bar4.py").write_text("print('Importing bar4')")# Changing sys.path temporarilywithlocate.prepend_sys_path("foo"):print(f"I can temporarily import from:{Path(this_dir,'foo')}")importbar1print()print(f"I can no longer import from:{Path(this_dir,'foo')}")try:importbar2exceptImportError:print("Cannot import bar2")print()# Changing sys.path permanentlylocate.prepend_sys_path("foo")print(f"I can now always import from:{Path(this_dir,'foo')}")importbar3importbar4print()OutputThis file is located in: C:\Users\simon

I can temporarily import from: C:\Users\simon\foo
Importing bar1

I can no longer import from: C:\Users\simon\foo
Cannot import bar2

I can now always import from: C:\Users\simon\foo
Importing bar3
Importing bar4MotivationThis package is for people who frequently use the directory of their scripts for storing files and custom modules and do
not want their pipeline to break from an interactive shell. This is based on how Julia thinks about the immediate
directory through its@__DIR__macro.locate.this_dir()is defined as:When running a.pyfile, this is the file's base directory.When running an.ipynnotebook, this is the current working directory. This is the desired/expected result since
Jupyter sets the working directory as the.ipynbbase directory by default.When running in a REPL, this is also the current working directory. This is similar to
Julia's@__DIR__macro.Other considerationsFor a good discussion on retrieving the current Python path, seehttps://stackoverflow.com/questions/3718657
Package: locate-pixelcolor
Locate RGB values in a picture! 40 x faster than PIL, 5 x faster than numpypipinstalllocate-pixelcolorfromlocate_pixelcolorimportsearch_colors# Let's use a 4525 x 6623 x 3 picture https://www.pexels.com/pt-br/foto/foto-da-raposa-sentada-no-chao-2295744/importcv2path=r"C:\Users\Gamer\Documents\Downloads\pexels-alex-andrews-2295744.jpg"img=cv2.imread(path)exa1=search_colors(pic=img,colors=[(255,255,255)])%timeitsearch_colors(pic=img,colors=[(255,255,255)])96.8ms±534µsperloop(mean±std.dev.of7runs,10loopseach)# You can search for up to 9 different colors at the same time:search_colors(pic=img,colors=[(255,255,255),(0,0,0)])%timeitsearch_colors(pic=img,colors=[(255,255,255),(0,0,0)])132ms±382µsperloop(mean±std.dev.of7runs,10loopseach)# Let's compare it with PILfromPILimportImageimg=Image.open(path)img=img.convert("RGB")datas=img.getdata()defget_coords_with_pil(col):newData=[]foritemindatas:ifitem[0]==col[0]anditem[1]==col[1]anditem[2]==col[2]:newData.append(item)returnnewData# %timeit get_coords_with_pil(col=(255, 255, 255))# 3.34 s ± 51.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
Package: locate-pixelcolor-c
Detects colors in images 10 x faster than Numpypip install locate-pixelcolor-cTested against Windows 10 / Python 3.10 / AnacondaHow to use it in Pythonimportnumpyasnpimportcv2fromlocate_pixelcolor_cimportsearch_colors# 4525 x 6623 x 3 picture https://www.pexels.com/pt-br/foto/foto-da-raposa-sentada-no-chao-2295744/picx=r"C:\Users\hansc\Downloads\pexels-alex-andrews-2295744.jpg"pic=cv2.imread(picx)colors0=np.array([[255,255,255]],dtype=np.uint8)resus0=search_colors(pic=pic,colors=colors0)colors1=np.array([(66,71,69),(62,67,65),(144,155,153),(52,57,55),(127,138,136),(53,58,56),(51,56,54),(32,27,18),(24,17,8),],dtype=np.uint8)resus1=search_colors(pic=pic,colors=colors1)####################################################################%timeitsearch_colors(pic=pic,colors=colors0)17.6ms±245µsperloop(mean±std.dev.of7runs,100loopseach)# last update: 16.3 msb,g,r=pic[...,0],pic[...,1],pic[...,2]%timeitnp.where(((b==255)&(g==255)&(r==255)))150ms±209µsperloop(mean±std.dev.of7runs,10loopseach)####################################################################%timeitresus1=search_colors(pic=pic,colors=colors1)138ms±10msperloop(mean±std.dev.of7runs,10loopseach)# last update: 117 ms%timeitnp.where(((b==66)&(g==71)&(r==69))|((b==62)&(g==67)&(r==65))|((b==144)&(g==155)&(r==153))|((b==52)&(g==57)&(r==55))|((b==127)&(g==138)&(r==136))|((b==53)&(g==58)&(r==56))|((b==51)&(g==56)&(r==54))|((b==32)&(g==27)&(r==18))|((b==24)&(g==17)&(r==8)))1s±16.1msperloop(mean±std.dev.of7runs,1loopeach)####################################################################The C Codevoidcolorsearch(unsignedchar*pic,unsignedchar*colors,intwidth,inttotallengthpic,inttotallengthcolor,int*outputx,int*outputy,int*lastresult){intcounter=0;for(inti=0;i<=totallengthcolor;i+=3){intr=colors[i];intg=colors[i+1];intb=colors[i+2];for(intj=0;j<=totallengthpic;j+=3){if((r==pic[j])&&(g==pic[j+1])&&(b==pic[j+2])){intdividend=j/3;intquotient=dividend/width;intremainder=dividend%width;intupcounter=counter;outputx[upcounter]=quotient;outputy[upcounter]=remainder;lastresult[0]=upcounter;counter++;}}}}// gcc -O2 -fPIC -shared -o cloop.so cloop.c
Package: locate-pixelcolor-cpp-parallelfor
Detects colors in images up to 10 x faster than Numpypip install locate-pixelcolor-cpp-parallelforTested against Windows 10 / Python 3.10 / AnacondaImportant!The module imports a function from a compiled .dll (C++).
If you get any import errors, install:https://download.visualstudio.microsoft.com/download/pr/8b92f460-7e03-4c75-a139-e264a770758d/26C2C72FBA6438F5E29AF8EBC4826A1E424581B3C446F8C735361F1DB7BEFF72/VC_redist.x64.exeHow to use it in Pythonimportcv2importnumpyasnpfromlocate_pixelcolor_cpp_parallelforimportsearch_colors# 4525 x 6623 x 3 picture https://www.pexels.com/pt-br/foto/foto-da-raposa-sentada-no-chao-2295744/picx=r"C:\Users\hansc\Downloads\pexels-alex-andrews-2295744.jpg"pic=cv2.imread(picx)colors0=np.array([[255,255,255]],dtype=np.uint8)resus0=search_colors(pic=pic,colors=colors0,cpus=5)colors1=np.array([(66,71,69),(62,67,65),(144,155,153),(52,57,55),(127,138,136),(53,58,56),(51,56,54),(32,27,18),(24,17,8),],dtype=np.uint8)resus1=search_colors(pic=pic,colors=colors1,cpus=4)print(resus1)##################################################################### Pretty good, but this one is better: https://github.com/hansalemaos/locate_pixelcolor_cpppragma%timeitresus0=search_colors(pic=pic,colors=colors0,cpus=5)69.4msÂ±302Âµsperloop(meanÂ±std.dev.of7runs,10loopseach)b,g,r=pic[...,0],pic[...,1],pic[...,2]%timeitnp.where(((b==255)&(g==255)&(r==255)))150msÂ±209Âµsperloop(meanÂ±std.dev.of7runs,10loopseach)####################################################################%timeitresus1=search_colors(pic=pic,colors=colors1,cpus=5)151msÂ±10.2msperloop(meanÂ±std.dev.of7runs,10loopseach)%timeitnp.where(((b==66)&(g==71)&(r==69))|((b==62)&(g==67)&(r==65))|((b==144)&(g==155)&(r==153))|((b==52)&(g==57)&(r==55))|((b==127)&(g==138)&(r==136))|((b==53)&(g==58)&(r==56))|((b==51)&(g==56)&(r==54))|((b==32)&(g==27)&(r==18))|((b==24)&(g==17)&(r==8)))1sÂ±16.1msperloop(meanÂ±std.dev.of7runs,1loopeach)####################################################################The C++ Code#include<atomic>#include<ppl.h>std::atomic<int>value(0);intcreate_id(){returnstd::atomic_fetch_add(&value,1);}extern"C"__declspec(dllexport)voidcolorsearch(char*pic,char*colors,intwidth,inttotallengthpic,inttotallengthcolor,int*outputx,int*outputy,int*lastresult){value=0;concurrency::parallel_for(0,totallengthcolor/3+1,[&](inti){intr=i*3;intg=i*3+1;intb=i*3+2;for(intj=0;j<=totallengthpic;j+=3){if((colors[r]==pic[j])&&(colors[g]==pic[j+1])&&(colors[b]==pic[j+2])){intdividend=j/3;intquotient=dividend/width;intremainder=dividend%width;intupcounter=create_id();outputx[upcounter]=quotient;outputy[upcounter]=remainder;lastresult[0]=upcounter;}}});}// cl.exe /std:c++20 /fp:fast /EHsc /Oi /Ot /Oy /Ob3 /GF /Gy /MD /openmp /LD cloop.cpp /Fe:cloop.dll
Package: locate-pixelcolor-cupy
Detects colors in images up to 8 times as fast as NumPypip install locate-pixelcolor-cupyIf you haven't installed cupy yet, I recommend you installing it using conda:
conda install -c conda-forge cupyTested against Windows 10 / Python 3.10 / AnacondaUsageimportnumpyasnpimportcv2fromlocate_pixelcolor_cupyimportsearch_colors# 4525 x 6623 x 3 picture https://www.pexels.com/pt-br/foto/foto-da-raposa-sentada-no-chao-2295744/picx=r"C:\Users\hansc\Downloads\pexels-alex-andrews-2295744.jpg"pic=cv2.imread(picx)colors0=np.array([[255,255,255]],dtype=np.uint8)resus0=search_colors(pic=pic,colors=colors0)colors1=np.array([(66,71,69),(62,67,65),(144,155,153),(52,57,55),(127,138,136),(53,58,56),(51,56,54),(32,27,18),(24,17,8),],dtype=np.uint8,)resus1=search_colors(pic=pic,colors=colors1)####################################################################%timeitresus0=search_colors(pic=pic,colors=colors0)78.2msÂ±1.29msperloop(meanÂ±std.dev.of7runs,1loopeach)b,g,r=pic[...,0],pic[...,1],pic[...,2]%timeitnp.where(((b==255)&(g==255)&(r==255)))150msÂ±209Âµsperloop(meanÂ±std.dev.of7runs,10loopseach)####################################################################%timeitresus1=search_colors(pic=pic,colors=colors1)139msÂ±9.78msperloop(meanÂ±std.dev.of7runs,1loopeach)%timeitnp.where(((b==66)&(g==71)&(r==69))|((b==62)&(g==67)&(r==65))|((b==144)&(g==155)&(r==153))|((b==52)&(g==57)&(r==55))|((b==127)&(g==138)&(r==136))|((b==53)&(g==58)&(r==56))|((b==51)&(g==56)&(r==54))|((b==32)&(g==27)&(r==18))|((b==24)&(g==17)&(r==8)))1sÂ±16.1msperloop(meanÂ±std.dev.of7runs,1loopeach)####################################################################
Package: locate-pixelcolor-cythonmulti
Detects colors in images 5-10 x faster than Numpypip install locate-pixelcolor-cythonmultiTested+compiled against Windows 10 / Python 3.10 / AnacondaIf you can't import it, compile it on your system (code at the end of this page)How to use it in Pythonimportnumpyasnpimportcv2fromlocate_pixelcolor_cythonmultiimportsearch_colors# 4525 x 6623 x 3 picture https://www.pexels.com/pt-br/foto/foto-da-raposa-sentada-no-chao-2295744/picx=r"C:\Users\hansc\Downloads\pexels-alex-andrews-2295744.jpg"pic=cv2.imread(picx)colors0=np.array([[255,255,255]],dtype=np.uint8)resus0=search_colors(pic=pic,colors=colors0)colors1=np.array([(66,71,69),(62,67,65),(144,155,153),(52,57,55),(127,138,136),(53,58,56),(51,56,54),(32,27,18),(24,17,8),],dtype=np.uint8)resus1=search_colors(pic=pic,colors=colors1)####################################################################%timeitresus0=search_colors(pic,colors0)32.3msÂ±279Âµsperloop(meanÂ±std.dev.of7runs,10loopseach)b,g,r=pic[...,0],pic[...,1],pic[...,2]%timeitnp.where(((b==255)&(g==255)&(r==255)))150msÂ±209Âµsperloop(meanÂ±std.dev.of7runs,10loopseach)####################################################################%timeitresus1=search_colors(pic,colors1)151msÂ±3.21msperloop(meanÂ±std.dev.of7runs,10loopseach)%timeitnp.where(((b==66)&(g==71)&(r==69))|((b==62)&(g==67)&(r==65))|((b==144)&(g==155)&(r==153))|((b==52)&(g==57)&(r==55))|((b==127)&(g==138)&(r==136))|((b==53)&(g==58)&(r==56))|((b==51)&(g==56)&(r==54))|((b==32)&(g==27)&(r==18))|((b==24)&(g==17)&(r==8)))1sÂ±16.1msperloop(meanÂ±std.dev.of7runs,1loopeach)####################################################################The Cython Code# distutils: language = c++# cython: language_level=3# distutils: extra_compile_args = /openmp# distutils: extra_link_args = /openmpfromcython.parallelcimportprangecimportcythonimportnumpyasnpcimportnumpyasnpimportcythonfromcollectionsimportdefaultdict@cython.boundscheck(False)@cython.wraparound(False)@cython.cdivision(True)cpdefsearchforcolor(unsignedchar[:]pic,unsignedchar[:]colors,intwidth,inttotallengthpic,inttotallengthcolor):cdefmy_dict=defaultdict(list)cdefinti,jcdefunsignedcharr,g,bforiinprange(0,totallengthcolor,3,nogil=True):r=colors[i]g=colors[i+1]b=colors[i+2]forjinrange(0,totallengthpic,3):if(r==pic[j])and(g==pic[j+1])and(b==pic[j+2]):withgil:my_dict[(r,g,b)].append(j)forkeyinmy_dict.keys():my_dict[key]=np.dstack(np.divmod(np.array(my_dict[key])//3,width))[0]returnmy_dictsetup.py to compile the code# distutils: language = c++# cython: language_level=3fromsetuptoolsimportExtension,setupfromCython.Buildimportcythonizeimportnumpyasnpext_modules=[Extension("colorsearchcythonmulti",["colorsearchcythonmulti.pyx"],include_dirs=[np.get_include()],define_macros=[("NPY_NO_DEPRECATED_API","NPY_1_7_API_VERSION")])]setup(name='colorsearchcythonmulti',ext_modules=cythonize(ext_modules),)# .\python.exe .\colorsearchcythonmultisetup.py build_ext --inplace