help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
dask-parallel
/
scripts
RSK World
dask-parallel
Parallel and distributed computing with Dask
scripts
  • advanced_data_processing.py6.6 KB
  • create_basic_data.py4.9 KB
  • distributed_workflow.py4.3 KB
  • generate_advanced_data.py6.8 KB
  • memory_efficient_ops.py3.6 KB
  • parallel_processing.py2.2 KB
  • performance_profiling.py6 KB
parallel_processing.py
scripts/parallel_processing.py
Raw Download
Find: Go to:
#!/usr/bin/env python3
"""
Parallel Processing with Dask
Author: Molla Samser
Designer & Tester: Rima Khatun
Website: https://rskworld.in
Email: help@rskworld.in, support@rskworld.in
Phone: +91 93305 39277
"""

import dask.array as da
import numpy as np
import time
from dask import delayed, compute


def parallel_array_operations():
    """Demonstrate parallel array operations"""
    print("=" * 60)
    print("Parallel Array Operations")
    print("=" * 60)
    
    # Create large arrays
    print("\nCreating large arrays...")
    array1 = da.random.random((5000, 5000), chunks=(1000, 1000))
    array2 = da.random.random((5000, 5000), chunks=(1000, 1000))
    
    # Perform parallel operations
    print("Performing parallel operations...")
    start_time = time.time()
    
    result = (array1 + array2) * 2
    sum_result = result.sum()
    final = sum_result.compute()
    
    end_time = time.time()
    
    print(f"Result: {final}")
    print(f"Computation time: {end_time - start_time:.2f} seconds")
    print()


def parallel_data_processing():
    """Demonstrate parallel data processing with delayed functions"""
    print("=" * 60)
    print("Parallel Data Processing")
    print("=" * 60)
    
    @delayed
    def process_chunk(data):
        """Process a chunk of data"""
        time.sleep(0.1)  # Simulate processing
        return data.sum()
    
    # Create multiple data chunks
    print("\nCreating data chunks...")
    chunks = [np.random.rand(1000, 1000) for _ in range(10)]
    
    # Process in parallel
    print("Processing chunks in parallel...")
    start_time = time.time()
    
    tasks = [process_chunk(chunk) for chunk in chunks]
    results = compute(*tasks)
    
    end_time = time.time()
    
    print(f"Processed {len(results)} chunks")
    print(f"Total time: {end_time - start_time:.2f} seconds")
    print(f"Results: {[r for r in results]}")
    print()


def main():
    """Main function"""
    print("\nDask Parallel Processing Examples")
    print("=" * 60)
    
    parallel_array_operations()
    parallel_data_processing()
    
    print("=" * 60)
    print("All examples completed!")
    print("=" * 60)


if __name__ == "__main__":
    main()

90 lines•2.2 KB
python

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer